I have written the below code which access a query to obtain a list of email address and a certain store for those email addresses as the criteria for my report then automatically emails this report to those users.
When I run this on my computer everything works perfectly but i have since installed this on a clients pc and it gives me the error message in the TITLE
Any ideas would be great
Here is the code that is used.
Thanks in Advance
When I run this on my computer everything works perfectly but i have since installed this on a clients pc and it gives me the error message in the TITLE
Any ideas would be great
Here is the code that is used.
Code:
Private Sub cmdVIEW_Click()
Dim strrpt As String
Dim strwhere As String
Dim today As String
today = Format(Now(), "ddmmyy")
If Me.frameREPORT = 4 Then
DoCmd.Close
Call AUTOTILLTOTALS
End If
End Sub
Public Function AUTOTILLTOTALS()
Dim rsemail As DAO.Recordset
Dim stremail As String
Dim strstore As String
Dim strsmtp As String
Dim strfrom As String
Set rsemail = CurrentDb.OpenRecordset("qryEMAILS")
Do While Not rsemail.EOF
stremail = rsemail.Fields("TO").Value
strstore = rsemail.Fields("STORE").Value
strsmtp = rsemail.Fields("SMTP").Value
strfrom = rsemail.Fields("FROM").Value
Call report_autoemail("rptTILLTOTALS", "TILL TOTALS", stremail, strfrom, strsmtp, strstore)
rsemail.MoveNext
Loop
End Function
Public Sub report_autoemail(strrpt As String, _
subject As String, strtoemail As String, _
strfromemail As String, _
strsmtp As String, strstore As String)
Dim today As String
Dim objMessage As Object
Dim sendto As String
Dim stwhere As String
today = Format(Now(), "ddmmyy")
stwhere = "STORE LIKE " & strstore
'this option outputs the report to a pdf document then emails it to certain email addresses
Set objMessage = CreateObject("CDO.Message")
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strsmtp
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.subject = subject
sendto = strtoemail
objMessage.from = strfromemail
objMessage.to = sendto
objMessage.Bcc = ""
objMessage.CC = ""
objMessage.TextBody = "TFRS CUSTOM REPORTS"
DoCmd.OpenReport strrpt, acViewPreview, , stwhere
DoCmd.OutputTo acOutputReport, strrpt, acFormatPDF, "C:\TFRS REPORTS\" & strrpt & today & ".PDF"
objMessage.AddAttachment "C:\TFRS REPORTS\" & strrpt & today & ".PDF"
objMessage.Send
DoCmd.Close
End Sub
Thanks in Advance