How to Tell Whether a Form Is Open

Why do you need to know whether a form is open? If you want to retrieve some data from a form, you might use an expression such as the following:

strState = Forms!LossesArg!AccidentState 

The line runs if the form is open. It fails if the form is closed, whether it is a pop-up form or not. Consequently, there are times when you need a way to determine whether the form is loaded. The following procedure determines whether a specific form is loaded in the database:

 Function IsFormOpen(frm As String) As Boolean Dim objAccess As AccessObject, dbObject As Object Set dbObject = Application.CurrentProject 'Browse AllForms collection for loaded form For Each objAccess In dbObject.AllForms If objAccess.IsLoaded = ...

Get Access 2002 Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.