Results 1 to 3 of 3
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Prompt Print Dialog

    HI



    Code:
    DoCmd.SelectObject acReport, "MyReport"
    DoCmd.RunCommand acCmdPrint
    i used above code to get the printer selection prompt. but when i click on cancel button on the prompt screen i get the below error

    "The Run Command Action Was Cancelled", how can i ignore the above error?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    With error handling:

    http://www.baldyweb.com/ErrorTrap.htm

    for that particular error, don't include the message box.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,706
    You need an error handler to ignore the error, which I think is 2501
    Code:
    Sub cmdPrint_Click()
        On Error GoTo cmdPrint_Click_Error
        DoCmd.SelectObject acReport, "MyReport"
        DoCmd.RunCommand acCmdPrint
    cmdPrint_Click_EXIT:
        Exit Sub
    cmdPrint_Click_Error:
        Select Case Err
            Case 2501   'do nothing, cancelled
            Case Else
                MsgBox Err.Number & ", " & Err.Description
        End Select
        Resume cmdPrint_Click_EXIT
    End Sub
    Last edited by davegri; 06-01-2018 at 08:33 AM. Reason: aesthetics

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 09-03-2015, 06:01 PM
  2. Modifying contol to show Print dialog
    By chayes2 in forum Access
    Replies: 3
    Last Post: 07-21-2015, 12:45 PM
  3. Print current record, open printer dialog box
    By Jamesiv1 in forum Access
    Replies: 7
    Last Post: 05-19-2014, 11:15 AM
  4. Open Print Dialog when Report is opened
    By tylerg11 in forum Reports
    Replies: 1
    Last Post: 01-09-2014, 10:44 AM
  5. Replies: 3
    Last Post: 09-18-2013, 04:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums