I am sending emails from MS Access by outlook using following command
DoCmd.SendObject acSendReport, report_name, acFormatPDF, my_email, , my_email, "Weekly", "Sending you weekly report", True
where report_name is a report based on a query qQuickReport.
But I do not want to send all records to all recipients. Each recipient should receive his own records from the report. Creating 5 separate queries and 5 forms based on this forms is one of the options, but I would prefer to do it "properly". So I plan to loop recipient ID in the query qQuickReport adding a following condition:
WHERE (((qALL.Koordinator)=[whichone]))
and set parameter [whichone] by VBA code as follows:
DoCmd.SetParameter "whichone", "4"
Following two lines work fine if I open only query qQuickReport, it contains only records belonging to recipient 4:
DoCmd.SetParameter "whichone", "4"
DoCmd.OpenQuery ("qQuickReport")
But If I try to use it as follows:
DoCmd.SetParameter "whichone", "4"
DoCmd.SendObject acSendReport, report_name, acFormatPDF, my_email, , my_email, "Weekly", "Sending you weekly report", True
it asks me to input parameter [whichone] interactively (window Enter Parameter Value), so it means that query under the Report did not receive a value of the parameter [which].
Am I doing anything wrong or simply Setparameter with SendReport is not supported?
Thanks, PH