Can anyone help. I have the following code which loops through a recordset and emails a report covering the departments to their budget holder. Some budget holders have more than one department. The details of the departments are in a table. I have the following on the click event of a command button. it works fine in that it emails each budget holder the relevant report but as it loops through the list it emails the same report more than once to the same person as they appear in the list of dept and budget holders more than once. how can I exclude the duplicates?
Private Sub Command3_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("qryCostCentreMultiple", dbOpenDynaset)
rs.MoveFirst
Do
vOfficeID = rs("email")
DoCmd.SendObject acSendReport, "rptAutoEmailMultiple", "pdfFormat(*.pdf)", rs("Email"), "", "", "Monthly Report", "Please find attached a breakdown of the current details for your Cost Centres., True
rs.MoveNext
Loop Until rs.EOF
rs.Close
db.Close
End Sub
Private Sub Command3_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("qryCostCentreMultiple", dbOpenDynaset)
rs.MoveFirst
Do
vOfficeID = rs("email")
DoCmd.SendObject acSendReport, "rptAutoEmailMultiple", "pdfFormat(*.pdf)", rs("Email"), "", "", "Monthly Report", "Please find attached a breakdown of the current details for your Cost Centres., True
rs.MoveNext
Loop Until rs.EOF
rs.Close
db.Close
End Sub