patkeaveney
Registered User.
- Local time
- Today, 23:58
- Joined
- Oct 12, 2005
- Messages
- 75
I can't seem to successfully deal with this error.
The scenario is as follows. I call the above routine when the user clicks on a save button I have added to the form, which launches an email. with the option of having the User see it first. That works fine.
If the user chooses to not send the email however, and hits the email's close button to Cancel the send, I get Error 2051 popping up in Access.
I built code to trap the error, but it is not working. The error process is not being reached.
Can someone plese help.
Private Sub SendConfirmationEMail()
On Error GoTo SendConfirmationEMail_Err
Dim strTo As String
Dim strCC As String
Dim strSubject As String
Dim strMsgBody As String
EMailOK = False
strSubject = "FOI Request Confirmation - " & Me.txtIntRefCode
If Len(Me.ReqEmailAddress & vbNullString) = 0 Then
EMailOK = True
Exit_SendConfirmationEMail:
Exit Sub
SendConfirmationEMail_Err:
Select Case Err.Number
Case 2501 'Traps Error 2501
MsgBox "E-Mail Was Cancelled", , "Cancelled"
Resume Exit_SendConfirmationEMail
Case Else
MsgBox "Other Error" & Err.Description 'Will show every other error
Resume Exit_SendConfirmationEMail
End Select
End Sub
The scenario is as follows. I call the above routine when the user clicks on a save button I have added to the form, which launches an email. with the option of having the User see it first. That works fine.
If the user chooses to not send the email however, and hits the email's close button to Cancel the send, I get Error 2051 popping up in Access.
I built code to trap the error, but it is not working. The error process is not being reached.
Can someone plese help.
Private Sub SendConfirmationEMail()
On Error GoTo SendConfirmationEMail_Err
Dim strTo As String
Dim strCC As String
Dim strSubject As String
Dim strMsgBody As String
EMailOK = False
strSubject = "FOI Request Confirmation - " & Me.txtIntRefCode
If Len(Me.ReqEmailAddress & vbNullString) = 0 Then
MsgBox "Cannot Send EMail" & vbCrLf & vbCrLf _
& "No E-mail Address Entered for " & vbCrLf & vbCrLf _
& cmbRequestorName.Column(1), vbExclamation, "E-Mail not Sent"
Exit Sub
Else& "No E-mail Address Entered for " & vbCrLf & vbCrLf _
& cmbRequestorName.Column(1), vbExclamation, "E-Mail not Sent"
Exit Sub
strTo = Me.ReqEmailAddress
strCC = "patrick.keaveney@somepct.nhs.uk"
strMsgBody = vbCrLf & _
Me.cmbRequestorName.Column(3) & vbCrLf & vbCrLf _
& "Many thanks for your request for information under the freedom of information act." & vbCrLf & vbCrLf _
& "I acknowledge receipt of your request and confirm that this is now receiving action." & vbCrLf _
& "A response will be sent to you in due course" & vbCrLf & vbCrLf _
& "Please note the reference number for your request is " & Me.txtIntRefCode & vbCrLf & vbCrLf _
& "Kind Regards"
DoCmd.SendObject , , , strTo, strCC, , strSubject, strMsgBody, True
End If strCC = "patrick.keaveney@somepct.nhs.uk"
strMsgBody = vbCrLf & _
Me.cmbRequestorName.Column(3) & vbCrLf & vbCrLf _
& "Many thanks for your request for information under the freedom of information act." & vbCrLf & vbCrLf _
& "I acknowledge receipt of your request and confirm that this is now receiving action." & vbCrLf _
& "A response will be sent to you in due course" & vbCrLf & vbCrLf _
& "Please note the reference number for your request is " & Me.txtIntRefCode & vbCrLf & vbCrLf _
& "Kind Regards"
DoCmd.SendObject , , , strTo, strCC, , strSubject, strMsgBody, True
EMailOK = True
Exit_SendConfirmationEMail:
Exit Sub
SendConfirmationEMail_Err:
Select Case Err.Number
Case 2501 'Traps Error 2501
MsgBox "E-Mail Was Cancelled", , "Cancelled"
Resume Exit_SendConfirmationEMail
Case Else
MsgBox "Other Error" & Err.Description 'Will show every other error
Resume Exit_SendConfirmationEMail
End Select
End Sub