G
Guest
I have the following code which is for looping through each department
(Approximately 200) and sending a separate e-mail to the recipient listed in
a report. I am getting an error 3075( Missing operator) on line qdf.SQL =
strSQL and can't figure out the issue. VBA newbie still trying to figure out
how to create bug free code. Thanks in advance for any assistance you can
offer.
Private Sub cmdEmailReports_Click()
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim strBaseSQL As String
Set qdf = CurrentDb.QueryDefs("qryAGHSvcCode")
strBaseSQL = qdf.SQL
Set rst = CurrentDb.OpenRecordset(strBaseSQL)
With rst
Do Until .EOF
strSQL = Left(strBaseSQL, Len(strBaseSQL) - 3)
strSQL = strSQL & " WHERE [Expr1]='" & ![Expr1] & " '"
qdf.SQL = strSQL
DoCmd.SendObject acSendReport, "rptAGHLateCharges",
"SnapshotFormat(*.snp)", !Recipient, , , "YourSubject", "YourMessage", False
.MoveNext
Loop
.Close
End With
qdf.SQL = strBaseSQL
Set qdf = Nothing
Set rst = Nothing
End Sub
(Approximately 200) and sending a separate e-mail to the recipient listed in
a report. I am getting an error 3075( Missing operator) on line qdf.SQL =
strSQL and can't figure out the issue. VBA newbie still trying to figure out
how to create bug free code. Thanks in advance for any assistance you can
offer.
Private Sub cmdEmailReports_Click()
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim strBaseSQL As String
Set qdf = CurrentDb.QueryDefs("qryAGHSvcCode")
strBaseSQL = qdf.SQL
Set rst = CurrentDb.OpenRecordset(strBaseSQL)
With rst
Do Until .EOF
strSQL = Left(strBaseSQL, Len(strBaseSQL) - 3)
strSQL = strSQL & " WHERE [Expr1]='" & ![Expr1] & " '"
qdf.SQL = strSQL
DoCmd.SendObject acSendReport, "rptAGHLateCharges",
"SnapshotFormat(*.snp)", !Recipient, , , "YourSubject", "YourMessage", False
.MoveNext
Loop
.Close
End With
qdf.SQL = strBaseSQL
Set qdf = Nothing
Set rst = Nothing
End Sub