I'm trying to run this code:
Private Sub Command5_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT Last Name, Email FROM T_Inspectors;")
While Not rs.EOF
DoCmd.OpenReport "CurrentJobs", acViewPreview, , "Last Name='" & rs!LastName & "'"
DoCmd.SendObject acSendReport, , acFormatPDF, rs!Email, , , "Current Jobs", "Please contact Tracy with any concerns 415-525-0000", True
DoCmd.Close acReport, "CurrentJobs", acSaveNo
rs.MoveNext
Wend
End Sub
***************
The problem is in red above. The error keeps going to db as DAO.Database. (Do I need to add anything to the db?) Not sure why.
Also rs!LastName. When I try to put a space between it doesn't let me. The field is Last Name not LastName. So I'm not sure if it would work without the space.
Can you assist?