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

Code for closing 2nd form

Status
Not open for further replies.

KerryL

Technical User
May 7, 2001
545
0
0
US
I'm trying to add code to a cmd button so that it will close the active form and a second form, then return the user to the main menu. However, I'm having trouble with the argument to close the 2nd form and need help with the syntax. Here's what I have:

Active form = frmReports
Second form = frmRptCritera

Code:
Private Sub cmdRtnToMainMenu_Click()
On Error GoTo Err_cmdRtnToMainMenu_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmRptCriteria"
    DoCmd.Close stDocName, , , stLinkCriteria

    DoCmd.Close        

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Switchboard"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdRtnToMainMenu_Click:
    Exit Sub

Err_cmdRtnToMainMenu_Click:
    MsgBox Err.Description
    Resume Exit_cmdRtnToMainMenu_Click
    
End Sub
 


Code:
Private Sub cmdRtnToMainMenu_Click()
On Error GoTo Err_cmdRtnToMainMenu_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmRptCriteria"
    [COLOR=red]DoCmd.Close  acForm, stDocName [/color]

    DoCmd.Close        

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Switchboard"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdRtnToMainMenu_Click:
    Exit Sub

Err_cmdRtnToMainMenu_Click:
    MsgBox Err.Description
    Resume Exit_cmdRtnToMainMenu_Click
    
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top