Emailing multiple instances of a report programmatically

mhillerman

New member
Local time
Today, 06:36
Joined
Nov 23, 2012
Messages
1
I am having trouble figuring out the right design approach to the following problem. I have a query that I need to run that gives me a group of people that need a report generated for them, and each of their email addresses. For each person, I need to run the same report, but with a different parameter value (e.g. [Customer ID]='1234'). Each report instance must be emailed in PDF format to the corresponding email address.

I have created a report that is based on a Query that has a Parameter that can be entered by the user at run time. I was planning on getting a recordset of people that need a report run, looping through it and calling:

DoCmd.SendObject acSendReport, strReportName, acFormatPDF, _
strToEmail, , , strSubject, strBody, False

for each record in the recordset. However, there appears to be no way to programmatically pass Query Parameters from VBA to the report.
So, my question is this: what design approach should I use to solve this problem?

Thanks in advance for any help you can provide.

- Mike
 
There isn't a way to pass an argument to SendObject. If the report is always done for a single person then the easiest thing to do is to add a hidden field to the open form and have the query reference that hidden field. Then your code loop would change the value of the hidden field for each record in the loop.
 

Users who are viewing this thread

Back
Top Bottom