If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Close all open forms
Whats the best way to close all open forms and open another one
can it be done within the same command button so that if someone opens another form by clicking the relevant button the form that is already opened should close 1st Any Help would be great |
#2
|
|||
|
|||
This is one way
Public Function CloseAllForms(Optional ByVal ExceptName As String = vbNullString) Dim i As Integer Dim x As Integer x = Forms.Count - 1 For i = x To 0 Step -1 'The below will exclude a form if desired If Forms(i).Name ExceptName Then DoCmd.Close acForm, Forms(i).Name End If Next i End Function After this you could and an open form statement Jim -----Original Message----- Whats the best way to close all open forms and open another one can it be done within the same command button so that if someone opens another form by clicking the relevant button the form that is already opened should close 1st Any Help would be great . |
#3
|
|||
|
|||
Loop backwards through the Forms collection, issuing a Close on each one.
Dim lng As Long For lng = Forms.Count - 1 To 0 Step -1 DoCmd.Close acForm, Forms(lng).Name, acSaveNo Next Please be aware that there is a nasty bug in Access: If an edit is in progress, and cannot be saved (e.g. a required field has not yet been entered), it just closes the form and you lose your entry. More info: http://members.iinet.net.au/~allenbrowne/bug-01.html -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Mike" wrote in message news:41248297.0@entanet... Whats the best way to close all open forms and open another one can it be done within the same command button so that if someone opens another form by clicking the relevant button the form that is already opened should close 1st |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Icon shows open envelope in send folder. | Roger D. Thompson | General Discussion | 5 | August 11th, 2004 06:07 PM |
Document won't open | Bob Stubbs | General Discussion | 4 | August 3rd, 2004 05:45 AM |
closing multiple forms | MC | Using Forms | 4 | July 26th, 2004 09:13 PM |
docmd.close | Terri | General Discussion | 4 | July 20th, 2004 10:00 PM |
Open Macro after Close | Gerry Kuta | Worksheet Functions | 1 | October 23rd, 2003 02:25 PM |