Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing open Forms

Status
Not open for further replies.

jpinto

Technical User
Dec 12, 2003
75
PT
Hello,

I've a module with the following code:

Code:
Public Sub close_form(option As String)
Dim frm As Form

For Each frm In Forms
    If (frm.Name <> option) And (frm.Name <> "Startup") Then
        Unload frm
    End If
Next

End Sub

This is used when a user clicks on a button at the Startup form (MDI form), so that when we open a form, we should close any other form that was left open.

My problem is that this process is a little slow because I've several forms in my program and this function as to check all of them.

Is there another way to do it?

Thanks in advance.

João Pinto
 
Send to the immediate window the time it takes to unload each form along with the frm.name. Then when you find out which unload events are causing the problem deal with them.



Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
Can you please help me and tell me how to send the time it takes do unload each form and the form name to the immediate window?

Thanks,

João Pinto
 
I believe you're going to have a problem with option because it is a reserved word, so change to strOption

Public Sub close_form(strOptionAs String)
Dim frm As Form
Dim strTime As String
For Each frm In Forms
If (frm.Name <> strOption) And (frm.Name <> "Startup") Then
strTime = Timer
Unload frm
Debug.Print Timer - strTime & " Seconds to unload " & frm.Name
End If
Next
End Sub



Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top