detecting whether any forms are loaded

R

Robert Smith

hello,
I have a piece of code that determines the active
form as follows:

Set frmCurrentForm = Screen.ActiveForm

However when there are no forms active you get the error
message,
You entered and expression that requires a form to be the
active window.

How do we determine if a form is the active window so that
we can avoid running this command if there are no forms
loaded.

Regards
Robert
 
M

Mike M.T.

Function IsLoaded(strFrmName As String) As Boolean

' Determines if a form is loaded.

Const conFormDesign = 0
Dim intX As Integer

IsLoaded = False
For intX = 0 To Forms.Count - 1
If Forms(intX).FormName = strFrmName Then
If Forms(intX).CurrentView <> conFormDesign Then
IsLoaded = True
Exit Function ' Quit function once form has been found.
End If
End If
Next

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top