Microsoft Access 2010 Bible

(Rick Simeone) #1

Chapter 19: Advanced Access Form Techniques


693


FIGURE 19.4

The drop-down list for the Organizations combo box


Determining whether a form is open
The following code shows a function that reports whether the form passed in as strFName is cur-
rently open. It simply enumerates all members of the Forms collection, looking to see if strF-
Name matches the name of any open form.

Function IsFormOpen(strFName As String) As Integer
‘This function returns true if a form is open:
Dim i As Integer
‘Assume False:
IsFormOpen = False
For i = 0 To Forms.Count - 1
If Forms(i).Name = strFName Then
IsFormOpen = True
Exit Function
End If
Next
End Function

It’s probably worth pointing out that when you use a form as a subform, it does not actually appear
in the Forms collection, so that this function will not indicate that the form is open.
Free download pdf