report in the email body

kes

Registered User.
Local time
Today, 06:29
Joined
Mar 6, 2013
Messages
53
hi all,
I have a report that I'm attavhing to an email in a button click.
now I've been asked to also add the report to the email body.

I've tried several ways but none of them seems to work.
please see below my none working code:

Private Sub Command64_Click()
On Error GoTo Err
Dim message As String

Dim rs As Recordset
Dim vRecipientList As String
Dim vMsg As String
Dim vSubject As String
Dim strRep As Report_Summary

Set rs = CurrentDb.OpenRecordset("SELECT * FROM Mail_list")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do
If Not IsNull(rs!email) Then
vRecipientList = vRecipientList & rs!email & ";"
rs.MoveNext
Else
rs.MoveNext
End If

Loop Until rs.EOF
vMsg = "Site:" & Me.Customer_Name & vbCrLf & "Report:" & strRep
vSubject = "Supporter Daily Report"
DoCmd.SendObject acSendReport, "Summary", acFormatPDF, vRecipientList, , , vSubject, vMsg, True
MsgBox ("Report successfully eMailed!")


Else
MsgBox "No contacts."
End If


Exit Sub
Err:
Exit Sub

End Sub
 
Here seems you want to send the mail individualy to customer as the msg is taking one customer name and sending one attachment to many email IDs. Quite confused here.

Also setting up record set in SELECT query provide only email as it will be fast for query to run fetching one column only.

Your code by this seems fine only Summary have to be a report else will give error.
 
yes the summary is the reportI want to send.
but I geterror type mismatch...
any idea?
 
yes. I'm sorry, didn't know how to do that... now I know :)
I get it on the strRep part:

Code:
vMsg = "Site:" & Me.Customer_Name & vbCrLf & "Report:" & [B]strRep[/B]
 
The statement does not look like the culprit, when you get the error, if you click Debug, you will be taken to the VBA window, highlighting the line of error. Hover over it or use the immediate window to see what strRep generates..
 
done that... it's highlights the strRep...
 

Users who are viewing this thread

Back
Top Bottom