Make form open when all others closed

rtfanson

Registered User.
Local time
Today, 01:18
Joined
Jun 11, 2007
Messages
11
Hi.

Is there any way to make a form open up when every thing else is closed.

Can I make a macro that will check if everything else is closed and then open the startup form again?

Is anything like this possible?

Thanks
Richard
 
Anything is possible. :)

This will tell you the count of open forms in your DB (assign it to a button named "OpenForms"):

Code:
Private Sub OpenForms_Click()

    Dim fName As Form
    Dim FormCount As Byte
    
    On Error GoTo fName_Error
    FormCount = 0

    For Each fName In Application.Forms
        If Forms(fName).Visible Then
            FormCount = FormCount + 1
        End If
    Next

    If FormCount = 0 Then
        Forms([YourMainFormName]).Open
    End If

    Exit Sub

fName_Error:
    Resume Next

End Sub

All that is doing is cycling through each form in your DB. If the form is visible, then it's "open" as it were. If the form is not visible, you will get Error #2450; hence, the error checking routine to suppress that message and keep the code running.

EDIT: I made it applicable to your specific situation.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom