CharlesHerrick
Registered User.
- Local time
- Today, 14:16
- Joined
- Oct 28, 2003
- Messages
- 20
In Access 2000, I use a tab control form with an option group on each page as a menu to run various reports, triggered with a command button. When I click the command button and then try to Cancel a report based on a parameter query, I get a MS VB box with "Run-time error '2501'. The OpenReport action was canceled."
I tried to trap this error in my error routine in the tab form (see code) but debug statements inserted at the start of the error handler are not executed and the code hangs at the OpenReport command. The report uses SQL as the record source, although I get the same error by using the parameter query itself as the source. Can anyone help me with this? Thanks.
Private Sub cmdPreviewRpt_Click()
On Error GoTo ErrorHandler
Dim strDocName As String
Dim tbc As Control, pge As Page, ctl As Control
Dim ThisDate As String, S As String
Set tbc = Me!TabCtl0
Set pge = tbc.Pages(tbc.Value)
If pge.Name = "Customer" Then
Select Case grpCustomer
Case 1
strDocName = "rptCustPast?Months"
DoCmd.OpenReport strDocName, acViewPreview
Case 2
<more code>
End Select
End If
Exit_ErrorHandler:
Exit Sub
ErrorHandler:
If Err.Number = 2501 Then
Dim Msg As String
Msg = "Error Number: " & Err.Number & ", Description: " & Err.Description
MsgBox (Msg)
Resume Exit_ErrorHandler
End If
End Sub
I tried to trap this error in my error routine in the tab form (see code) but debug statements inserted at the start of the error handler are not executed and the code hangs at the OpenReport command. The report uses SQL as the record source, although I get the same error by using the parameter query itself as the source. Can anyone help me with this? Thanks.
Private Sub cmdPreviewRpt_Click()
On Error GoTo ErrorHandler
Dim strDocName As String
Dim tbc As Control, pge As Page, ctl As Control
Dim ThisDate As String, S As String
Set tbc = Me!TabCtl0
Set pge = tbc.Pages(tbc.Value)
If pge.Name = "Customer" Then
Select Case grpCustomer
Case 1
strDocName = "rptCustPast?Months"
DoCmd.OpenReport strDocName, acViewPreview
Case 2
<more code>
End Select
End If
Exit_ErrorHandler:
Exit Sub
ErrorHandler:
If Err.Number = 2501 Then
Dim Msg As String
Msg = "Error Number: " & Err.Number & ", Description: " & Err.Description
MsgBox (Msg)
Resume Exit_ErrorHandler
End If
End Sub