Runtime error 2501

J

Jamie S. Schaller

I have the following code listed below. Can anyone explain why I still get
the error message 2501, even though I have code to trap that error?

Private Sub cmdEmail_Click()

Dim strSQL As String

On Error GoTo Err_Handler

strSQL = "procRpt_ChangeRequest " & mintSourceType & ", " & mlngChangeID

'Process the pass-through query
Call PassThroughFixup("rpt_qrysptChangeRequest", strSQL,
strConnect:=Forms!frmLogin.ODBCConnect)

'Attach the report as a snapshot file to an email
DoCmd.SendObject acSendReport, "rptChangeRequest", acFormatSNP, , , ,
"Change Request #" & txtChangeNo.Value, "Attached please find a copy of the
change request.", True

Exit Sub

Err_Handler:
'If the user cancels the email message trap the error (#2501) and treat
'error like it does not exist
If Err.Number = 2501 Then
Exit Sub
Else
MsgBox Err.Number & " " & Err.Description
Exit Sub
End If
End Sub
 
A

Allan Murphy

Jamie

I use the following code for when a report has no data.

in the first line the Option line I have

Const ConErrRptCanceled = 2501

then in the preview area I have

Private Sub Preview_Click()


On Error GoTo Err_preview_Click

(enter your coding here to preview a report etc.)

Exit_preview_Click:
Exit Sub

Err_preview_Click:
If Err = ConErrRptCanceled Then
Resume Exit_preview_Click
Else
MsgBox Err.Description
Resume Exit_preview_Click
End If

End Sub

HTH
Allan Murphy
(e-mail address removed)
 
J

Jamie S. Schaller

Allan,
I tried what you suggested and still receive the error message, any
other suggestions?

Jamie S. Schaller
 

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