Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Microsoft: Access Forms FAQ

Form Basics

How To Check If A Form Is Loaded? by Schof
Posted: 21 Jul 04

The function below takes the name of a form as an input parameter and returns True/False if the form is loaded.

There is a second optional parameter that allows you to specify (by setting value to True that you want to know whether there is another form loaded other than the one specified in the first parameter.  

Place the code in a module and call it using something like:

If formIsLoaded("MyForm") Then ' MyForm is loaded

If formIsLoaded("MyForm", True) Then ' Some other form other than MyForm is loaded


' FUNCTION: formIsLoaded
' Determines whether the specified form OR
' another form other than the one specified
' is loaded.
Public Function formIsLoaded(ByVal vstrForm2Check As String, Optional ByVal vblnExcludingForm2Check As Boolean = False) As Boolean
On Error GoTo Err_formIsLoaded

    Dim aobForm As AccessObject

    For Each aobForm In Application.CurrentProject.AllForms
        If aobForm.IsLoaded Then
            If aobForm.name = vstrForm2Check And vblnExcludingForm2Check = False Then
                formIsLoaded = True
                Exit Function
            ElseIf aobForm.name <> vstrForm2Check And vblnExcludingForm2Check = True Then
                formIsLoaded = True
                Exit Function
            End If
        End If
    Next aobForm
    formIsLoaded = False
    Exit Function

    MsgBox Err.Description
    Resume Exit_formIsLoaded
End Function

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close