Run Time Error 2501

D

Denver

I have use this code to open my report and my form using Pass to Query

but i have this error 2501 when i try to click click.
***************here is my code***************************
On Error GoTo Proc_Error

Dim rsp As String
Dim Mynote As String

Mynote = "You will be sorting data by " & _
"Site Location-Discipline-Index respectively. " & _
vbCrLf & " " & _
vbCrLf & "Click Yes to plot the resulting criteria in a Report
View." & _
vbCrLf & "Click No to plot the resulting criteria in Datasheet
View, " & _
" or click Cancel to abort event."

rsp = MsgBox(Mynote, vbInformation + vbYesNoCancel, "Sort
Options")

If rsp = vbYes Then
DoCmd.OpenReport "SiteLocation-DisciplineIndex",
acViewPreview, , , acDialog

Else
DoCmd.CancelEvent 'cmd^do(0)
End If

If rsp = vbNo Then
DoCmd.OpenQuery "SiteLocation-DisciplineIndex",
acViewNormal, acReadOnly


Else
DoCmd.CancelEvent 'as^ is
End If
Exit Sub

'Then build my error trapping
Proc_Error:
If Err.Number = 2501 Then
'Do nothing as the user click cancenl button
Else 'Some other error, tell me about it
MsgBox Err.Number & ":" & Err.Description
End If
End Sub

*******************************************************

can anyone help me what do i miss here?
thanks, I appreciate for any help.
 
D

Denver

Denver said:
I have use this code to open my report and my form using Pass to Query

but i have this error 2501 when i try to click Cancel Button
***************here is my code***************************
On Error GoTo Proc_Error

Dim rsp As String
Dim Mynote As String

Mynote = "You will be sorting data by " & _
"Site Location-Discipline-Index respectively. " & _
vbCrLf & " " & _
vbCrLf & "Click Yes to plot the resulting criteria in a Report
View." & _
vbCrLf & "Click No to plot the resulting criteria in Datasheet
View, " & _
" or click Cancel to abort event."

rsp = MsgBox(Mynote, vbInformation + vbYesNoCancel, "Sort
Options")

If rsp = vbYes Then
DoCmd.OpenReport "SiteLocation-DisciplineIndex",
acViewPreview, , , acDialog

Else
DoCmd.CancelEvent 'cmd^do(0)
End If

If rsp = vbNo Then
DoCmd.OpenQuery "SiteLocation-DisciplineIndex",
acViewNormal, acReadOnly


Else
DoCmd.CancelEvent 'as^ is
End If
Exit Sub

'Then build my error trapping
Proc_Error:
If Err.Number = 2501 Then
'Do nothing as the user click cancenl button
Else 'Some other error, tell me about it
MsgBox Err.Number & ":" & Err.Description
End If
End Sub

*******************************************************

can anyone help me what do i miss here?
thanks, I appreciate for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top