UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Handling Error Of Cancel Sending An Email Through Ms Access, Access 2013    
 
   
Alhakeem1977
post Feb 16 2018, 11:50 AM
Post#1



Posts: 100
Joined: 8-July 17



Hi All,
"Handling error of cancel sending an email through MS Access"

I have a problem if I want to send an email then decided to cancel sending it I've got an error says " The send object was canceled ", I cannot close the form or anything it getting stuck.
Is there any way handle this error?
My code below:
CODE
'------------------------------------------------------------
' E_mail_Document_Click
'
'------------------------------------------------------------
Private Sub E_mail_Document_Click()
On Error GoTo MyError

DoCmd.SendObject acForm, "frmSubFacilitySearch", "PDFFormat(*.pdf)", "DMS@nbk.com", _
Cc:="", Subject:=DocID & " - Document Physical Retrieval Request.", _
MessageText:="Dear DC," & vbCrLf & " " & vbNewLine & _
"Kindly provide me with the physical document as per the attached request." & vbCrLf & _
"Document ID:" & "  " & DocID & " ." & vbCrLf & vbNewLine & _
"Your action is highly appreciated" & vbNewLine & vbNewLine & "Thank you!" & vbNewLine & vbNewLine & _
"Regards," & vbCrLf & _
"" & txtRN & "" & "", EditMessage:=True

Resume_MyError:
Exit Sub
On Error Resume Next
MyError:
Select Case Err.Number
Case 2501
GoTo Resume_MyError
Case Else
MsgBox "There was an error." & vbCrLf & Err.Number & vbCrLf & Err.Description
GoTo Resume_MyError
End Select

End Sub


Your prompt response in this matter would be highly appreciated.

Thanks in advance.

Regards,
Al Hakeem1977

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 
Alhakeem1977
post Feb 18 2018, 09:35 PM
Post#2



Posts: 100
Joined: 8-July 17



pullhair.gif Anyone can help please.
How can I modify the code above to avoid the error?
Regards,
Alhakeem1977

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 
ScottGem
post Feb 19 2018, 12:57 PM
Post#3


UtterAccess VIP / UA Clown
Posts: 32,203
Joined: 21-January 04
From: LI, NY


Try it this way:

CODE
Resume_MyError:
Exit Sub

MyError:
Select Case Err.Number
Case 2501
GoTo Resume_MyError
Case Else
MsgBox "There was an error." & vbCrLf & Err.Number & vbCrLf & Err.Description
GoTo Resume_MyError
End Select


The On Error Resume Next was throwing you into a loop

--------------------
Scott <>
Scottgem's Blog
Microsoft Access MVP since 2007
Author: Microsoft Office Access 2007 VBA
Go to the top of the page
 
Alhakeem1977
post Feb 19 2018, 02:33 PM
Post#4



Posts: 100
Joined: 8-July 17



Thanks for your response, it's still the same getting stuck the database.
the code I put it after your recommendation is below:

CODE
Private Sub Email_Document_Click()
On Error GoTo MyError

     DoCmd.SendObject acForm, "frmSubFacilitySearch", "PDFFormat(*.pdf)", "XXX@XXX.com", _
     Cc:="", Subject:=DocID & " - Document Physical Retrieval Request.", _
     MessageText:="Dear DC," & vbCrLf & " " & vbNewLine & _
     "Kindly provide me with the physical document as per the attached request." & vbCrLf & _
     "Document ID:" & "  " & DocID & " ." & vbCrLf & vbNewLine & _
     "Your action is highly appreciated" & vbNewLine & vbNewLine & "Thank you!" & vbNewLine & vbNewLine & _
     "Regards," & vbCrLf & _
     "" & txtRN & "" & "", EditMessage:=True

Resume_MyError:
Exit Sub

MyError:
Select Case Err.Number
Case 2501
GoTo Resume_MyError
Case Else
MsgBox "There was an error." & vbCrLf & Err.Number & vbCrLf & Err.Description
GoTo Resume_MyError
End Select

End Sub


Thanks in advance
This post has been edited by Alhakeem1977: Feb 19 2018, 02:34 PM

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 
Alhakeem1977
post Feb 21 2018, 02:03 PM
Post#5



Posts: 100
Joined: 8-July 17



pullhair.gif
Anyone can help, please.

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    18th June 2018 - 02:35 PM