?
Solved

User cancels report run but getting debug message box

Posted on 2008-10-24
4
Medium Priority
?
267 Views
Last Modified: 2013-11-25
I have a report that depends on critiera being passed at the form level.  However, if the user cancels the process when the request for a date comes up, the error message 2501 comes up.  I have code that works if the report is run directly and it works.  Howevever, the error trap does not work in this sceanrios and I am wondering how to get around it.  So, the user clicks on the button to run the report, the box requesting a date comes up and if they hit cancel, then the 2501 error box comes up.  It may be placement of the error, but I do not know where.
Private Sub boxUserManStats_Click()
Dim intCancel As Integer
DoCmd.OpenReport "rptUserManStats", acViewPreview, , "tblProductionData.Division = 'EDS' AND " & _
                                                "tblProductionData.DataSource = 'EDSManual' AND " & _
                                                "tblProductionData.UserID = '" & Me.txtUserID & "' AND " & _
                                                "tblProductionData.ActivityDate = [Enter Date in format of M/D/YYYY] "
Exit_ErrorHandler:
    Exit Sub
ErrorHandler:
    If Err.Number = 2501 Then
        Exit Sub
    Else
        MsgBox Err.Number & ": " & Err.Description
        Resume Exit_ErrorHandler
    End If
    
End Sub

Open in new window

0
Comment
Question by:ssmith94015
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 75
ID: 22798322
Try this - change button name, etc:

Private Sub cmdPrintApp_Click()
    On Error GoTo Err_cmdPrintApp_Click
    DoCmd.OpenReport "SomeReportName", acPreview

Exit_cmdPrintApp_Click:
    Exit Sub
Err_cmdPrintApp_Click:
    If Err.Number = 2501 then   ' You cancelled .....
         ' no action required
    Else
         MsgBox Err.Description
    End If
    Err.Clear
    Goto Exit_cmdPrintApp_Click
End Sub

mx
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 22798329
You are missing the

On Error Goto <your error handler>

mx
0
 

Author Comment

by:ssmith94015
ID: 22798437
I need to get some sleep.......
0
 

Author Closing Comment

by:ssmith94015
ID: 31509741
I am still working on the other issue as well.  
0

Featured Post

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question