M Joomun wrote:
> I have a difficult problem with a database. We have patients from
> multiple GP Practices. We need to send these practices an individual
> report with the results for their patients, say on a monthly basis.
> There may be up to 80 practices.
>
> I think I understand how to, say, send one email containing one report
> to one practice,
Are you intending to send it as a snapshot? Or do you intend to export it to
Excel or rich text and email the result?
> or one email containing one report to many practices,
> but to send an individually tailored report/email to eighty practices
> has me stumped.
>
> Would I need to create 80 results reports? How would I loop through
> the recordset of 80 practises?
>
> If anyone has any pointers I would be really grateful.
>
> TIA.
Never had to do it but this would be my plan:
Create a single report that can be filtered to produce each practice's
results.
Assuming you have a table containing the email addresses, add a column or
columns to contain the filter values for the report .
In a button's event procedure, open a recordset on the table containing the
email addresses and filter values.
Assign the report to a Report variable (a variable of type Report).
Loop through the recordset. In each pass through the loop, use the filter
values from the recordset to build a filter string to assign to the report
variable's Filter property. Then run the report and send it to the email
address from the recordset (I don't remember, is there a SendReport method
of a Report object?).
There may be more nuances that depend on the version of Access you are
using, so be sure to provide that information to us. If you are using 2007
or later, I will need to defer to other posters because there may be
features in those later versions to make this task easier.
PS. I just had a thought: instead of storing filter values in multiple
columns in the email table, use a single column to contain an entire filter
string. Then in the loop, assign the filter string directly to the report's
Filter property rather than constructing it in code.