Results 1 to 2 of 2
  1. #1
    docholliday is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    10

    Error Handling Question

    Hi all,



    I am still learning code and am having issues setting up the error handler for the below code. I have a button on a report that will export the report as either an Excel spreadsheet or a PDF, based on what the user selects on an option group on the report.

    Code:
    Private Sub Command239_Click()
    
    Select Case Me!ExportSelection
    
    
    Case 1
    
    
    DoCmd.OutputTo acOutputReport, "Chain Sales", "Excel97-Excel2003Workbook(*.xls)", "", False, "", , acExportQualityPrint
    
    
    
    
    Case 2
    
    
    DoCmd.OutputTo acOutputReport, "Chain Sales", "PDFFormat(*.pdf)", "", False, "", , acExportQualityPrint
    
    
    End Select
     
    End Sub

    The code seems to work fine - it brings up the appropriate window for saving the report in the right format. But when I click "cancel", I get an error message, likely because I don't have an error handler in place.

    Any thoughts on an error check?

  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,521
    Here are the basics:

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

    in your case, you probably don't want a message box for that particular error.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Error Handling Question - On Error Goto
    By redbull in forum Programming
    Replies: 7
    Last Post: 12-06-2012, 07:54 AM
  2. Replies: 3
    Last Post: 09-05-2012, 10:23 AM
  3. Error 2501 displays with Error handling
    By agent- in forum Programming
    Replies: 13
    Last Post: 08-05-2011, 02:20 PM
  4. Error Handling
    By trb5016 in forum Access
    Replies: 2
    Last Post: 08-10-2010, 08:37 AM
  5. #error handling
    By mws5872 in forum Access
    Replies: 4
    Last Post: 05-12-2010, 07:06 AM

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