something like:
the form (fMyForm) has a listbox (lstClients) of all clients
the code will cycle thru a listbox , get next name, , creating the pdf file
the query (in the report) uses the listbox to pull only that person selected in the list.
i.e.: select * from table where [ClientID]=forms!fMyForm!lstClients
the folder, vLoc , is also in the listbox in another column. col 3, but in vb code columns start with zero
Code:
sub btnGo_click()
Dim i As Integer
dim vItm, vSendTo
Code:
vDir = "c:\temp\"
For i = 0 To lstClients.ListCount - 1
vItm= lstClients.ItemData(i) 'get next item in list data
lstClients =vItm 'set listbox to that item
vSendTo = lstClients.column(1) 'get clients email addr. (note in VB, columns begin with zero)
vLoc = lstClients.column(2) 'col 3 has folder name, but in vb code, columns begin with zero, so col3 = lstClients.column(2)
vFilename = "rInvoice_" & vLoc & ".pdf"
vFile = vDir & vFileName
'create invoice data file
docmd.OutputTo acOutputReport ,"rInvoice",acFormatPDF,vFile
'or
docmd.OutputTo acOutputQuery ,"qsMyQuery",acFormatPDF,vFile
'email invoice directly
DoCmd.SendObject acSendReport, "rInvoice", acFormatPDF, vSendTo, , , "Subject", "message"
Next
end sub