Run-Time Error '2501'

G

Guest

I have a Cmd Btn that I have setup so the user can send an E-mail. I use the
following:

Private Sub Command1362_Click()
DoCmd.SendObject acSendNoObject, , , "(e-mail address removed)", , ,
"College First Pay Inquiry for " & [name] , " A Pay Inquiry is being
requested For " & [indiv_name], , True
End Sub

It works great! BUT if the user does not send the Email from outlook he gets
the following Msg.

Run-Time Error '2501'
The SendObject Action was canceled.

I would like it to show a MSG like.

Your Email has not been sent, OK
 
B

Brian

KAnoe said:
I have a Cmd Btn that I have setup so the user can send an E-mail. I use the
following:

Private Sub Command1362_Click()
DoCmd.SendObject acSendNoObject, , , "(e-mail address removed)", , ,
"College First Pay Inquiry for " & [name] , " A Pay Inquiry is being
requested For " & [indiv_name], , True
End Sub

It works great! BUT if the user does not send the Email from outlook he gets
the following Msg.

Run-Time Error '2501'
The SendObject Action was canceled.

I would like it to show a MSG like.

Your Email has not been sent, OK

Private Sub Command1362_Click()
Dim lngErr As Long
On Error Resume Next
DoCmd.SendObject acSendNoObject, , , "(e-mail address removed)", ,
, "College First Pay Inquiry for " & [name] , " A Pay Inquiry is being
requested For " & [indiv_name], , True
lngErr = Err
On Error GoTo 0
Select Case lngErr
Case 0
Case 2501
MsgBox "Your email has not been sent"
Case Else
Err.Raise lngErr
End Select

End Sub
 
G

Guest

You need an error handler. Here's an example.

Private Sub Command1362_Click()
On Error GoTo Err_Handler
Docmd.SendObject...
Exit Sub
Err_Handler:
Select Case Err
Case 2501
MsgBox "Your email has not been sent",vbOKOnly,"Alert"
Resume Next
Case Else
MsgBox Err.Description,vbCritical,"Error #" & Err.Number
Resume Next
End Select
End Sub
 
G

Guest

Thank you Brian and Elwin

Brian said:
KAnoe said:
I have a Cmd Btn that I have setup so the user can send an E-mail. I use the
following:

Private Sub Command1362_Click()
DoCmd.SendObject acSendNoObject, , , "(e-mail address removed)", , ,
"College First Pay Inquiry for " & [name] , " A Pay Inquiry is being
requested For " & [indiv_name], , True
End Sub

It works great! BUT if the user does not send the Email from outlook he gets
the following Msg.

Run-Time Error '2501'
The SendObject Action was canceled.

I would like it to show a MSG like.

Your Email has not been sent, OK

Private Sub Command1362_Click()
Dim lngErr As Long
On Error Resume Next
DoCmd.SendObject acSendNoObject, , , "(e-mail address removed)", ,
, "College First Pay Inquiry for " & [name] , " A Pay Inquiry is being
requested For " & [indiv_name], , True
lngErr = Err
On Error GoTo 0
Select Case lngErr
Case 0
Case 2501
MsgBox "Your email has not been sent"
Case Else
Err.Raise lngErr
End Select

End Sub
 

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

Similar Threads


Top