Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Run Time Error 2501

Geek News

Run Time Error 2501
Denver 12/5/2008 5:01:00 AM
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.
RE: Run Time Error 2501
Denver 12/6/2008 4:40:00 AM


"Denver" wrote:

[Quoted Text]
> 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.

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net