• Print Report and Close Forms (2002 (XP))

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Print Report and Close Forms (2002 (XP))

    Author
    Topic
    #377487

    I am trying to add some code to a button that prints a report. What I want to happen is to have the user click the print button and have the form print then have it automatically close all the open forms and leave just the switchboard open. My code isn’t working here it is. Think I am just naming the forms wrong.

    Private Sub Command82_Click()
    On Error GoTo Err_Command82_Click

    Dim stDocName As String

    stDocName = “Main Table”
    DoCmd.OpenReport stDocName, acNormal
    DoCmd.Close , Form![PSTP1]
    DoCmd.Close , Form![PSTP2]
    DoCmd.Close , Form![PSTP3]

    Exit_Command82_Click:
    Exit Sub

    Err_Command82_Click:
    MsgBox Err.Description
    Resume Exit_Command82_Click

    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #621777

      Give this bit of code a try:

      DoCmd.Close acForm, “PSTP1”

      and repeat it for the other form names.
      Hope that helps.

    Viewing 0 reply threads
    Reply To: Print Report and Close Forms (2002 (XP))

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: