I'm just learning VBA so I am easily confused by it. I've designed a database which queries the main table looking for dates that are equal to the current date. I built a form and report based on this query. The email address is in the query, form, and report, but it varies depending on the individual record. When I try to get it to email based on the email in the query, I fail miserably. I've got it to the point where it tries to send, but I get an invalid argument and this is boggling me. Any help will be appreciated.
Code that I've done so far:
Function mail()
On Error GoTo mail_Err
Dim strSQL As String
Dim rsnewquery As Recordset
DoCmd.OpenForm "newquery", acNormal, "", "", , acNormal
DoCmd.Minimize
DoCmd.OpenReport "newquery", acViewPreview, "", ""
Set db = CurrentDb
Set rsnewquery = db.OpenRecordset("newquery", dbOpenSnapshot)
rsnewquery.MoveFirst
Do Until rsnewquery.EOF
DoCmd.SendObject acReport, "newquery", "SnapshotFormat(*.snp)", " Query![newquery]![R/O] ", "", "", "TEST DO NOT REPLY...Just Delete", "feedback due", False, ""
DoCmd.GoToRecord acQuery, "newquery", acNext, 1
rsnewquery.MoveNext
Loop
rsnewquery.Close
mail_Exit:
Exit Function
mail_Err:
MsgBox Error$
Resume mail_Exit
End Function
Code that I've done so far:
Function mail()
On Error GoTo mail_Err
Dim strSQL As String
Dim rsnewquery As Recordset
DoCmd.OpenForm "newquery", acNormal, "", "", , acNormal
DoCmd.Minimize
DoCmd.OpenReport "newquery", acViewPreview, "", ""
Set db = CurrentDb
Set rsnewquery = db.OpenRecordset("newquery", dbOpenSnapshot)
rsnewquery.MoveFirst
Do Until rsnewquery.EOF
DoCmd.SendObject acReport, "newquery", "SnapshotFormat(*.snp)", " Query![newquery]![R/O] ", "", "", "TEST DO NOT REPLY...Just Delete", "feedback due", False, ""
DoCmd.GoToRecord acQuery, "newquery", acNext, 1
rsnewquery.MoveNext
Loop
rsnewquery.Close
mail_Exit:
Exit Function
mail_Err:
MsgBox Error$
Resume mail_Exit
End Function