B
Bob Vance
Basically I have PDF format for my emails, but is it possible that on my
form
frmCompanyInfo I can have a true/false check box
[frmCompantInfo.EmailOption]
True = PDF, False SNP
So I would have to change my string to accommodate the option
Below are parts of my strings that "PDF" would have to be changed to I
suppose something like
If frmCompantInfo.EmailOption = 0 "PDF" Else "SNP"
Private Sub Report_Activate()
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
CurrentDb.Execute "UPDATE tblOwnerInfo " & _
"SET Emaildate = Now() " & _
"WHERE OwnerID = " & lngID, dbFailOnError
dtInvDate = Me.tbTodayDate 'xxx
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("PDF")
msgTitle = "E-Mail Sender"
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, acFormatPDF, To:=strMail,
Cc:=DLookup("EmailCC", "tblOwnerInfo", "OwnerID = " & lngID),
Bcc:=DLookup("EmailBCC", "tblOwnerInfo", "OwnerID = " & lngID), _
Subject:="Your Invoice" & IIf(Len(strHorse) > 0, " / " & strHorse, ""),
MessageText:=strBodyMsg, EditMessage:=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 '
DoCmd.Close acReport, "rptInvoiceModifyEmail", acSaveNo
End If
Exit Sub
Error_Handler:
Select Case Err.Number
Case 2501
Exit Sub
Case 2487
Resume Next
Case Else
End Select
End Sub
Public Function DownloadMessage( _
Optional strFileType As String = "PDF", _
Optional strMessage As String = _
"To open this file you will need Adobe Reader. If you do not have this on
your computer, you are able to download it for FREE at ") _
As String
Dim strLink As String
Select Case strFileType
Case "rtf" 'MSWord
strLink =
"http://www.microsoft.com/downloads/...7-8732-48d5-8689-ab826e7b8fdf&DisplayLang=en "
Case "Snp" 'Snapshot
strLink = "http://support.microsoft.com/kb/175274"
Case "PDF" 'Adobe Acrobat
strLink = "http://www.adobe.com"
Case "XLS" 'Excel
strLink =
"http://www.microsoft.com/downloads/...f4-996c-4569-b547-75edbd03aaf0&displaylang=EN"
Case Else
DownloadMessage = ""
Exit Function
End Select
DownloadMessage = Chr(13) _
& strMessage & Chr(10) & Chr(10) & Chr(13) & strLink _
& Chr(10) & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) &
Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) &
"================================================================"
End Function
Private Sub SendMailButton_Click()
On Error GoTo ErrorHandler
Dim lngID As Long, strMail As String, strBodyMsg As String, _
blEditMail As Boolean, sndReport As String, strCompany As String
'*****JK: Added 17/10/06
Dim msgPmt As String, msgBtns As Integer, msgTitle As String, msgResp As
Integer
Select Case Me.OpenArgs
Case "OwnerStatement"
sndReport = "rptOwnerPaymentMethod"
lngID = Nz(Me.cbOwnerName.Column(0), 0)
strMail = OwnerEmailAddress(lngID)
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 Statement, Dated" & " " & Format(Date,
"d-mmm-yyyy") & eMailSignature("Best Regards", True) & Chr(10) & Chr(10) &
DownloadMessage("PDF") _
CurrentDb.Execute "UPDATE tblOwnerInfo " & _
"SET EmailDateState = Now() " & _
"WHERE OwnerID = " & lngID, dbFailOnError
'DoCmd.SendObject acSendReport, sndReport, acFormatPDF, strMail, , , "Your
Statement" & " " & "/" & " " & Nz(DLookup("[CompanyName]",
"tblCompanyInfo")), strBodyMsg, True
DoCmd.SendObject acSendReport, sndReport, acFormatPDF, strMail,
Cc:=DLookup("EmailCC", "tblOwnerInfo", "OwnerID = " & lngID),
Bcc:=DLookup("EmailBCC", "tblOwnerInfo", "OwnerID = " & lngID), _
Subject:="Your Statement" & " / " & Nz(DLookup("[CompanyName]",
"tblCompanyInfo")), MessageText:=strBodyMsg 'EditMessage:=blEditMail
cbOwnerName.SetFocus
Case Else
Exit Sub
End Select
Exit Sub
ErrorHandler:
msgTitle = "Untrapped Error"
msgBtns = vbExclamation
If Err.Number = 2501 Then
Err.Clear
Exit Sub
End If
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Description: " & Err.Description & Chr(13) & Chr(13) _
& "(frmBillStatement SendMailButton_Click)", msgBtns, msgTitle
End Sub
form
frmCompanyInfo I can have a true/false check box
[frmCompantInfo.EmailOption]
True = PDF, False SNP
So I would have to change my string to accommodate the option
Below are parts of my strings that "PDF" would have to be changed to I
suppose something like
If frmCompantInfo.EmailOption = 0 "PDF" Else "SNP"
Private Sub Report_Activate()
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
CurrentDb.Execute "UPDATE tblOwnerInfo " & _
"SET Emaildate = Now() " & _
"WHERE OwnerID = " & lngID, dbFailOnError
dtInvDate = Me.tbTodayDate 'xxx
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("PDF")
msgTitle = "E-Mail Sender"
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, acFormatPDF, To:=strMail,
Cc:=DLookup("EmailCC", "tblOwnerInfo", "OwnerID = " & lngID),
Bcc:=DLookup("EmailBCC", "tblOwnerInfo", "OwnerID = " & lngID), _
Subject:="Your Invoice" & IIf(Len(strHorse) > 0, " / " & strHorse, ""),
MessageText:=strBodyMsg, EditMessage:=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 '
DoCmd.Close acReport, "rptInvoiceModifyEmail", acSaveNo
End If
Exit Sub
Error_Handler:
Select Case Err.Number
Case 2501
Exit Sub
Case 2487
Resume Next
Case Else
End Select
End Sub
Public Function DownloadMessage( _
Optional strFileType As String = "PDF", _
Optional strMessage As String = _
"To open this file you will need Adobe Reader. If you do not have this on
your computer, you are able to download it for FREE at ") _
As String
Dim strLink As String
Select Case strFileType
Case "rtf" 'MSWord
strLink =
"http://www.microsoft.com/downloads/...7-8732-48d5-8689-ab826e7b8fdf&DisplayLang=en "
Case "Snp" 'Snapshot
strLink = "http://support.microsoft.com/kb/175274"
Case "PDF" 'Adobe Acrobat
strLink = "http://www.adobe.com"
Case "XLS" 'Excel
strLink =
"http://www.microsoft.com/downloads/...f4-996c-4569-b547-75edbd03aaf0&displaylang=EN"
Case Else
DownloadMessage = ""
Exit Function
End Select
DownloadMessage = Chr(13) _
& strMessage & Chr(10) & Chr(10) & Chr(13) & strLink _
& Chr(10) & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) &
Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) &
"================================================================"
End Function
Private Sub SendMailButton_Click()
On Error GoTo ErrorHandler
Dim lngID As Long, strMail As String, strBodyMsg As String, _
blEditMail As Boolean, sndReport As String, strCompany As String
'*****JK: Added 17/10/06
Dim msgPmt As String, msgBtns As Integer, msgTitle As String, msgResp As
Integer
Select Case Me.OpenArgs
Case "OwnerStatement"
sndReport = "rptOwnerPaymentMethod"
lngID = Nz(Me.cbOwnerName.Column(0), 0)
strMail = OwnerEmailAddress(lngID)
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 Statement, Dated" & " " & Format(Date,
"d-mmm-yyyy") & eMailSignature("Best Regards", True) & Chr(10) & Chr(10) &
DownloadMessage("PDF") _
CurrentDb.Execute "UPDATE tblOwnerInfo " & _
"SET EmailDateState = Now() " & _
"WHERE OwnerID = " & lngID, dbFailOnError
'DoCmd.SendObject acSendReport, sndReport, acFormatPDF, strMail, , , "Your
Statement" & " " & "/" & " " & Nz(DLookup("[CompanyName]",
"tblCompanyInfo")), strBodyMsg, True
DoCmd.SendObject acSendReport, sndReport, acFormatPDF, strMail,
Cc:=DLookup("EmailCC", "tblOwnerInfo", "OwnerID = " & lngID),
Bcc:=DLookup("EmailBCC", "tblOwnerInfo", "OwnerID = " & lngID), _
Subject:="Your Statement" & " / " & Nz(DLookup("[CompanyName]",
"tblCompanyInfo")), MessageText:=strBodyMsg 'EditMessage:=blEditMail
cbOwnerName.SetFocus
Case Else
Exit Sub
End Select
Exit Sub
ErrorHandler:
msgTitle = "Untrapped Error"
msgBtns = vbExclamation
If Err.Number = 2501 Then
Err.Clear
Exit Sub
End If
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Description: " & Err.Description & Chr(13) & Chr(13) _
& "(frmBillStatement SendMailButton_Click)", msgBtns, msgTitle
End Sub