MS Access 2007: Check if a form is loaded
This MSAccess tutorial explains how to check if a form is already loaded in a session in Access 2007 (with screenshots and step-by-step instructions).
See solution in other versions of Access:
Question: In Microsoft Access 2007, how do I check to see if a form is already loaded in an Access session?
Answer: It is often useful in Access programming to know whether a form is already loaded. To do this, you can use the function IsLoaded.
For example:
If CurrentProject.AllForms("Suppliers").IsLoaded = True Then ... End If
This code checks to see if the form called Suppliers has been loaded in the current Access session.
Here is an example of how we've used IsLoaded.
Function GetCity() as string If CurrentProject.AllForms("Suppliers").IsLoaded = True Then GetCity = Form_Suppliers.txtSupplier_City Else GetCity = "" End If End Function
This function is used to retrieve the value of the txtSupplier_City in the Suppliers form.
If the Suppliers form is loaded, it will return the value in the textbox called txtSupplier_City. If the form is not loaded, it will return a blank value. This helps us avoid errors if we try to access the txtSupplier_City value when the Suppliers form is not loaded.
You can then use this function in a Query or a Report. or for that matter, anywhere within your Access database.
Advertisements