In a form ,it has a listbox and 2 date fields: txtStartDate, txtEndDate
make a query to show the list of those who are to get an invoice, inside the 2 date fields:
select * from table where [dueDate] between forms!fMyForm!txtStartDate and forms!fMyForm!txtEndDate
add this query to the listbox: lstbox.rowsource = "qsInvoicesDue"
next use this code below to cycle thru the list and email invoice, (or just make a pdf)
the list box will have the ClientID and email.
the report will reference the 1 client in the list.
when 1 client id is selected in the listbox, the report query pulls only that client:
select * from query where [clientID]= forms!fMyFoirm!lstBox
button to cycle thru a listbox
Code:
sub btnSend_click()
Dim i As Integer
dim vItm
Code:
For i = 0 To lstBox.ListCount - 1
vItm= lstBox.ItemData(i) 'get next item in list data
lstBox = vItm 'set listbox to the item
'now get values from field columns
vName = lstBox.column(0) 'in vb, columns start with zero
vEmail = lstBox.column(1) 'get email from listbox ,col.2
'do stuff with it here
vFile = "c:\temp\Report_" & vName & ".pdf"
docmd.OutputTo acOutputQuery ,acQuery,acFormatPDF,vFile
'email if needed
DoCmd.SendObject acSendReport, "rMyReport", acFormatPDF, vEmail, , , "Subject", "message"
Next
end sub