Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Determine If a Form Exists in a Database


View products that this article applies to.

This article was previously published under Q210597
Moderate: Requires basic macro, coding, and interoperability skills.

↑ Back to the top


Summary

This article shows you how to create a Visual Basic for Application procedure to determine if a form exists in a database. If the form is in the database, the function opens it; otherwise, you get a message box stating that the form does not exist in this database.

↑ Back to the top


More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
Sub FormOpener(FormToOpen As String)

   Dim obj As AccessObject
   
   For Each obj In CurrentProject.AllForms
      If obj.Name = FormToOpen Then
         DoCmd.OpenForm FormToOpen
         Exit Sub
      End If
   Next
   
   MsgBox FormToOpen & " does not exist in this database."
   
End Sub
				

↑ Back to the top


References

For more information about the AllForms collection, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type allforms collection in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB210597, kbdta, kbprogramming, kbhowto

↑ Back to the top

Article Info
Article ID : 210597
Revision : 2
Created on : 6/23/2005
Published on : 6/23/2005
Exists online : False
Views : 357