I have a Save command button that I created using the Access built-in wizard. The On Click event saves the current record, generates an email (via Outlook) and creates a hyperlink on the form. The save function works fine.
If I place the email code before the hyperlink code, the email is created but not the hyperlink - and vice versa. Both pieces of code seem to work fine on their own. What do I need to do to make sure that both blocks of code run and not just the first one? Do I have a problem with the syntax of my End and Exit statements?
I'm a bit of a newbie so likely have some bug in the code.
Thanks in advance for any help you might be able to give.
CODE
Private Sub cmdSaveRecord_Click()
'Saves current record
On Error GoTo Err_cmdSaveRecord_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'2005-09-21
''Creates hyperlink to underlying client response file/image
Dim strInputEmail As String
Dim strInputRightFax As String
'Dim strInputViewFinder As String
Const strPathEmail = "\\Sew00016.maple.fg.rbc.com\wrkgrp\CCA RESPONSE TRACKING\CART Email\"
Const strPathRightFax = "\\Sew00016.maple.fg.rbc.com\wrkgrp\CCA RESPONSE TRACKING\CART RightFax\"
Const strPathViewFinder = "\\Sew00016.maple.fg.rbc.com\wrkgrp\CCA RESPONSE TRACKING\CART ViewFinder\"
strInputEmail = strPathEmail & Me.txtIDnumber & ".msg"
strInputRightFax = strPathRightFax & Me.txtIDnumber & ".tif"
strInputViewFinder = strPathViewFinder & Me.txtIDnumber & ".pdf"
If Me.lstDeliveryMethod = "email" Then
Me.txtHyperlink = strInputEmail
ElseIf Me.lstDeliveryMethod = "RightFax" Then
Me.txtHyperlink = strInputRightFax
ElseIf Me.lstDeliveryMethod = "ViewFinder" Then
Me.txtHyperlink = strInputViewFinder
End If
Exit Sub
'2005-09-28
'email to management for unsolicited instructions
Dim strEmailAddresses As String
strEmailAddresses = "xyz@abc.com"
If Me.chkUnsolicitedInstructions = -1 Then
DoCmd.SendObject , "", "", strEmailAddresses & "", "", "", "Unsolicited Response RECEIVED - " & _
"Property: " & Me.txtPropertyName & _
" Client: " & Me.cboClientName.Column(1), _
"Response Tracking has received an 'Unsolicited Instruction' " & _
"It has been logged in CART. Processing coordinators are to action instructions " & _
"within 48 hours of receipt." & _
vbCrLf & vbCrLf & _
"CART ID: " & Me.txtIDnumber & _
vbCrLf & vbCrLf & _
"Client: " & Me.cboClientName.Column(1) & _
vbCrLf & _
"Account Number (where available): " & Me.txtAccountNumber & _
vbCrLf & vbCrLf & _
"Property: " & Me.txtPropertyName & _
vbCrLf & _
"Event Type: " & Me.cboEventType.Column(1) & _
vbCrLf & _
"CCA Number (where available): " & Me.txtCCAnumber & _
vbCrLf & vbCrLf & _
"Staff Name: " & Me.lstStaffName & _
vbCrLf & _
vbCrLf & "Please contact the above listed staff if further details are required."
Exit Sub
End If
Exit_cmdSaveRecord_Click:
Exit Sub
Err_cmdSaveRecord_Click:
If Err.Number <> 2501 Then
MsgBox Err.Number & "; " & Err.Description
End If
Resume Exit_cmdSaveRecord_Click
End Sub
'Saves current record
On Error GoTo Err_cmdSaveRecord_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'2005-09-21
''Creates hyperlink to underlying client response file/image
Dim strInputEmail As String
Dim strInputRightFax As String
'Dim strInputViewFinder As String
Const strPathEmail = "\\Sew00016.maple.fg.rbc.com\wrkgrp\CCA RESPONSE TRACKING\CART Email\"
Const strPathRightFax = "\\Sew00016.maple.fg.rbc.com\wrkgrp\CCA RESPONSE TRACKING\CART RightFax\"
Const strPathViewFinder = "\\Sew00016.maple.fg.rbc.com\wrkgrp\CCA RESPONSE TRACKING\CART ViewFinder\"
strInputEmail = strPathEmail & Me.txtIDnumber & ".msg"
strInputRightFax = strPathRightFax & Me.txtIDnumber & ".tif"
strInputViewFinder = strPathViewFinder & Me.txtIDnumber & ".pdf"
If Me.lstDeliveryMethod = "email" Then
Me.txtHyperlink = strInputEmail
ElseIf Me.lstDeliveryMethod = "RightFax" Then
Me.txtHyperlink = strInputRightFax
ElseIf Me.lstDeliveryMethod = "ViewFinder" Then
Me.txtHyperlink = strInputViewFinder
End If
Exit Sub
'2005-09-28
'email to management for unsolicited instructions
Dim strEmailAddresses As String
strEmailAddresses = "xyz@abc.com"
If Me.chkUnsolicitedInstructions = -1 Then
DoCmd.SendObject , "", "", strEmailAddresses & "", "", "", "Unsolicited Response RECEIVED - " & _
"Property: " & Me.txtPropertyName & _
" Client: " & Me.cboClientName.Column(1), _
"Response Tracking has received an 'Unsolicited Instruction' " & _
"It has been logged in CART. Processing coordinators are to action instructions " & _
"within 48 hours of receipt." & _
vbCrLf & vbCrLf & _
"CART ID: " & Me.txtIDnumber & _
vbCrLf & vbCrLf & _
"Client: " & Me.cboClientName.Column(1) & _
vbCrLf & _
"Account Number (where available): " & Me.txtAccountNumber & _
vbCrLf & vbCrLf & _
"Property: " & Me.txtPropertyName & _
vbCrLf & _
"Event Type: " & Me.cboEventType.Column(1) & _
vbCrLf & _
"CCA Number (where available): " & Me.txtCCAnumber & _
vbCrLf & vbCrLf & _
"Staff Name: " & Me.lstStaffName & _
vbCrLf & _
vbCrLf & "Please contact the above listed staff if further details are required."
Exit Sub
End If
Exit_cmdSaveRecord_Click:
Exit Sub
Err_cmdSaveRecord_Click:
If Err.Number <> 2501 Then
MsgBox Err.Number & "; " & Err.Description
End If
Resume Exit_cmdSaveRecord_Click
End Sub