Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Set qdf=CurrentDB.QueryDefs("qryReport")
Set rs=CurrentDB.OpenRecorset("tblSuppliers")
strSQL=qdf.SQL
Do While Not rs.EOF
strSQLSup = strSQL & " WHERE SupplierID=" & rs!SupplierID
qdf.SQL=strSQLSup
DoCmd.SendObject acSendReport, "rptSupplier", acFormatRTF, rs!Email
rs.MoveNext
Loop
qdf.SQL=strSQL
'Get the query that the report is based on
Set qdf=CurrentDB.QueryDefs("qryReport")
'Open the suppliers recordset
Set rs=CurrentDB.OpenRecorset("tblSuppliers")
'Get the sql of the query the report is based on
'this is a sketch, so I have assumed that the SQL is
'does not have a Where statement. More on this in a
'line or two
strSQL=qdf.SQL
'Loop through the suppliers recordset
Do While Not rs.EOF
'Add a Where statement to the report SQL so
'only the current supplier from the recordset
'is included
strSQLSup = strSQL & " WHERE SupplierID=" & rs!SupplierID
'Set the report query SQL to the altered sql statement
qdf.SQL=strSQLSup
'Email the report, which now only includes the one
'supplier to the email from the supplier recordset
DoCmd.SendObject acSendReport, "rptSupplier", acFormatRTF, rs!Email
'And so to the next supplier
rs.MoveNext
Loop
'Set the query back to the usual SQL
qdf.SQL=strSQL