B
Bob Vance
I have a code which on deactivate of report if Owner has an email address
the report is emailed, can I add to the code:
Enter today's date to table/field tblOwnerInfo.Emaildate to the same
"OwnerID"
Thanks for any help....Bob
Private Sub Report_Deactivate()
On Error GoTo Error_Handler
Dim lngID As Long, strMail As String, strBodyMsg As String, _
blEditMail As Boolean, dtInvDate As Date, varInvNum As Variant, _
idHorse As Long, strHorse As String
Dim msgPmt As String, msgBtns As Integer, msgTitle As String, msgResp
As Integer
If CurrentProject.AllForms("frmModify").IsLoaded = True Then
lngID = DLookup("OwnerID", "tblInvoice", "InvoiceID = " _
& Form_frmModify.lstModify.Column(0))
ElseIf CurrentProject.AllForms("frmModifyInvoiceClient").IsLoaded = True
Then
lngID = DLookup("OwnerID", "tblInvoice", "InvoiceID = " _
& Form_frmModifyInvoiceClient.lstModify.value)
Else
Exit Sub
End If
strMail = Nz(DLookup("Email", "tblOwnerInfo", "OwnerID = " & lngID), "")
If Not IsEmailOn Or Not IsOwnerWithEmail(lngID) Then
Exit Sub
End If
dtInvDate = Me.tbInvoiceDate
varInvNum = Me.tbInvoiceNumber
idHorse = Nz(Me.tbHorseID, 0)
If idHorse <> 0 Then
strHorse = Nz(DLookup("[Name]", "qryHorseNameAll", "[HorseID]=" &
idHorse), "")
Else
strHorse = ""
End If
strBodyMsg = "Dear "
strBodyMsg = strBodyMsg & Nz(DLookup("[ClientTitle]", "tblOwnerInfo",
"[OwnerID]=" & lngID), " ") & " "
strBodyMsg = strBodyMsg & Nz(DLookup("[OwnerLastName]", "tblOwnerInfo",
"[OwnerID]=" & lngID), " Owner")
strBodyMsg = strBodyMsg & "," & Chr(10) & Chr(10) & Chr(13) _
& "Attached is your " & varInvNum & " Dated " & Format(dtInvDate,
"d-mmm-yyyy") _
& IIf(Len(strHorse) > 0, " for " & strHorse, "") & "." _
& eMailSignature("Best Regards", True) & Chr(10) & Chr(10) & Chr(13) _
& DownloadMessage("snp")
If strMail = "Null" Or Len(strMail) = 0 Or _
DLookup("[MailFlag]", "tblAdminSetup") = False Then
Exit Sub
End If
msgTitle = "E-Mail"
msgBtns = vbYes + vbQuestion + vbDefaultButton2 + vbApplicationModal
msgPmt = " Create E-mail "
msgResp = MsgBox(msgPmt, msgBtns, msgTitle)
If msgResp = vbCancel Then
Exit Sub
Else
blEditMail = IIf(msgResp = vbYes, False, True)
End If
DoCmd.SendObject acSendReport, Me.Name, acFormatSNP, strMail, , , "Your
Invoice " & IIf(Len(strHorse) > 0, " / " & strHorse, ""), _
strBodyMsg, blEditMail
Exit Sub
If MsgBox("Do you want to send Email??", vbYesNo + vbDefaultButton2)
= vbYes Then
DoCmd.SendObject acSendReport, Me.Name, acFormatRTF,
strMail, , , _
"Your Invoice", strBodyMsg, True
End If
Exit Sub
Error_Handler:
Select Case Err.Number
Case 2501
Exit Sub
Case 2487
Resume Next
Case Else
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Description: " & Err.Description, , "Untrapped Error"
End Select
End Sub
the report is emailed, can I add to the code:
Enter today's date to table/field tblOwnerInfo.Emaildate to the same
"OwnerID"
Thanks for any help....Bob
Private Sub Report_Deactivate()
On Error GoTo Error_Handler
Dim lngID As Long, strMail As String, strBodyMsg As String, _
blEditMail As Boolean, dtInvDate As Date, varInvNum As Variant, _
idHorse As Long, strHorse As String
Dim msgPmt As String, msgBtns As Integer, msgTitle As String, msgResp
As Integer
If CurrentProject.AllForms("frmModify").IsLoaded = True Then
lngID = DLookup("OwnerID", "tblInvoice", "InvoiceID = " _
& Form_frmModify.lstModify.Column(0))
ElseIf CurrentProject.AllForms("frmModifyInvoiceClient").IsLoaded = True
Then
lngID = DLookup("OwnerID", "tblInvoice", "InvoiceID = " _
& Form_frmModifyInvoiceClient.lstModify.value)
Else
Exit Sub
End If
strMail = Nz(DLookup("Email", "tblOwnerInfo", "OwnerID = " & lngID), "")
If Not IsEmailOn Or Not IsOwnerWithEmail(lngID) Then
Exit Sub
End If
dtInvDate = Me.tbInvoiceDate
varInvNum = Me.tbInvoiceNumber
idHorse = Nz(Me.tbHorseID, 0)
If idHorse <> 0 Then
strHorse = Nz(DLookup("[Name]", "qryHorseNameAll", "[HorseID]=" &
idHorse), "")
Else
strHorse = ""
End If
strBodyMsg = "Dear "
strBodyMsg = strBodyMsg & Nz(DLookup("[ClientTitle]", "tblOwnerInfo",
"[OwnerID]=" & lngID), " ") & " "
strBodyMsg = strBodyMsg & Nz(DLookup("[OwnerLastName]", "tblOwnerInfo",
"[OwnerID]=" & lngID), " Owner")
strBodyMsg = strBodyMsg & "," & Chr(10) & Chr(10) & Chr(13) _
& "Attached is your " & varInvNum & " Dated " & Format(dtInvDate,
"d-mmm-yyyy") _
& IIf(Len(strHorse) > 0, " for " & strHorse, "") & "." _
& eMailSignature("Best Regards", True) & Chr(10) & Chr(10) & Chr(13) _
& DownloadMessage("snp")
If strMail = "Null" Or Len(strMail) = 0 Or _
DLookup("[MailFlag]", "tblAdminSetup") = False Then
Exit Sub
End If
msgTitle = "E-Mail"
msgBtns = vbYes + vbQuestion + vbDefaultButton2 + vbApplicationModal
msgPmt = " Create E-mail "
msgResp = MsgBox(msgPmt, msgBtns, msgTitle)
If msgResp = vbCancel Then
Exit Sub
Else
blEditMail = IIf(msgResp = vbYes, False, True)
End If
DoCmd.SendObject acSendReport, Me.Name, acFormatSNP, strMail, , , "Your
Invoice " & IIf(Len(strHorse) > 0, " / " & strHorse, ""), _
strBodyMsg, blEditMail
Exit Sub
If MsgBox("Do you want to send Email??", vbYesNo + vbDefaultButton2)
= vbYes Then
DoCmd.SendObject acSendReport, Me.Name, acFormatRTF,
strMail, , , _
"Your Invoice", strBodyMsg, True
End If
Exit Sub
Error_Handler:
Select Case Err.Number
Case 2501
Exit Sub
Case 2487
Resume Next
Case Else
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Description: " & Err.Description, , "Untrapped Error"
End Select
End Sub