I was wondering if someone can help me with the code below.
Table: T_Inspectors (this is where the email addresses are stored [Email])
Query: Q_WeeklyDispatch_Today (This is the parameter Date()
Report: R_WeeklyDispatch_Today. (Goal: This report sends to each employee with the jobs attached by email).
It does everything it needs to do up to the Emailing part. It is not connect the email address to the right report. It appears to be emails the report to the first person on the Table but not connecting at all to the query.
Can you take a look at the code below and let me know if I'm missing something?
Thank you
*********************************************
Private Sub Command5_Click()
Dim strCriteria As String
Dim strDate As String
Dim strEmail As String
strCriteria = "[Date]=" & strDate
DoCmd.OpenReport "R_WeeklyDispatch_Today", acViewPreview, , , acHidden
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("T_Inspectors", dbOpenDynaset) 'We need an email address
rs.MoveFirst
Do While Not rs.EOF 'Loop through every record in T_Inspectors and retreive emails
DoCmd.OpenReport "R_WeeklyDispatch_Today", acViewPreview, , "[Employee]='" & rs![Last Name] & "'"
DoCmd.SendObject acSendReport, "R_WeeklyDispatch_Today", acFormatPDF, strEmail, , , "Current Jobs", "Please contact Tracy with any concerns 415-525-0000", True
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
DoCmd.Close acReport, "R_WeeklyDispatch_Today"
End Sub