Multiple commands for 1 button?

AlfredNor

Registered User.
Local time
Today, 07:58
Joined
Sep 18, 2002
Messages
47
Im trying to make a command that closes the form you're in and goes back to the switchboard.

The Wizard only gives you one command...how/where do you add another?
 
Create a button that opens a form, look at the properties of the button, on the events tab you will see the On Click event with this next to it [Event Procedure], click the button [...] next to it.
Thsi will take you into the code which will look something like this...

Code:
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

    [i]Dim stDocName As String[/i]
    [i]Dim stLinkCriteria As String[/i]

    [i]stDocName = "tblAgeAtRetirementSample"[/i]
    [i]DoCmd.OpenForm stDocName, , , stLinkCriteria[/i]

Exit_Command5_Click:
    Exit Sub

Err_Command5_Click:
    MsgBox Err.Description
    Resume Exit_Command5_Click
    
End Sub


Delete the italicised code above and if the switchboard is open in the background, type this in its place

Docmd.Close
Forms("NameOfSwitchboard").SetFocus

If the form is not already open you'll need to replace the above with

Docmd.Close
Docmd.OpenForm "NameOfSwitchboard"
 
but

Ok. Im an idiot. Thanks.

Ive just realize that my switchboard stays open even after it opens the correct form...Ill just make one that closes the form your in.

Thanks though.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom