Mailing Reports

H

Hawksby

I have set-up some code to help me mail my reports to various parties. I
have had to do this in VB, as i wanted to add spaces between lines in the
body of the e-mail.

I now have a new issue:

1. If a report has no records how can i set the code up to either bring up
an error message or to send a seperate message saying "No transactions"
 
A

Allen Browne

Reports have a NoData event.
If you cancel this event, the report does not open.

In the code that uses OpenReport, trap error 2501.
In your error trapping, send the separate message.
To send that as an email, use SendObject with acNoObject
 
H

Hawksby

Sorry a slight mistake on my part. I actually sending Queries as apposed to
reports. The code i am using is as below. Is there away of adding the
nodata function to this?


Dim strMsg As String

strMsg = "All, " & vbCrLf & vbCrLf & "Please find attached today's report." _
& vbCrLf & vbCrLf & "If you require any further information, please do not
hesitate to contact me." _
& vbCrLf & vbCrLf & "Regards" & vbCrLf & vbCrLf & ""


DoCmd.SendObject acSendQuery, "Portfolio", acFormatXLS, _
"Name", , , "Sales", (strMsg), True
 
P

Peter Kinsman

Could you use a domain function

Records = Dcount("*", "Portfolio")
If Records > 0 Then SendQuery

Peter Kinsman
 
Top