I have a form that is brought up at startup (frmSteve) and I would like to run a query (qryOlder) in the "On Current" for that form. The query captures any record that is over 14 days old. What I need to do is send an automatic email to myself for each record that came up in the query.
The query works fine. The code I have to auto-email works fine. I am just completely clueless as to how to set up the code to loop through the query and run the auto-email code for each record.
After searching online, I found some code and tried plugging it in with mine just to see what happened. Here's what I came up with:
This emails the first record in the query results HUNDREDS of times and never makes it to the next record.
Any help is very much appreciated!!!
The query works fine. The code I have to auto-email works fine. I am just completely clueless as to how to set up the code to loop through the query and run the auto-email code for each record.
After searching online, I found some code and tried plugging it in with mine just to see what happened. Here's what I came up with:
Code:
Private Sub Form_Current()
Dim db As Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qryOlder")
Set rst = qdf.OpenRecordset()
Do Until rst.EOF
‘Code to send email (works perfect by itself)
Loop
rst.Close
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End Sub
Any help is very much appreciated!!!
Comment