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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(Access) Close all open forms.

Status
Not open for further replies.

xenofoob

Programmer
Oct 4, 2004
28
NL
Hello,

tried to search the forum but no threads found. Is there a way to close all the open forms?

HAve tried something like this:
Code:
    Dim i As Integer
    MsgBox (Forms.Count)
    For i = 0 To i = Forms.Count
        MsgBox (i)
    Next i
but it didn't work like I expected to.

Thanks a lot!
 
-edit-
offcouse the msgbox(i) should be replaced for something like Forms(i).close but the value i is nog increasing. The first message box says there are 4 forms open.
 
A good general principal for any closing or deleting actions within a loop is to count downwards:

For i = Forms.Count to 1 Step -1

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

For tsunami relief donations

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 

In VB I always use the forms collection, should work in VBA

Code:
Dim frm As Form
For Each frm In Forms
  Unload frm
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top