ACC2000: How to Determine If a Form Exists in a DatabaseID: Q210597
|
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.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals 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 needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
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
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.
Additional query words: vt inf
Keywords : kbprg kbdta PgmObj
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: July 6, 1999