Hi
I am new to coding.
I am trying to loop through a query that will show a form that reminds the user to follow up an event from last year.
My code is:
Public Function EventReminder()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("qryEventFollowUp")
Set rst = qdf.OpenRecordset()
With rst
Do Until .EOF
DoCmd.OpenForm FormName:="frmMessageBoxEventFollowUpEdit", WindowMode:=acDialog
.MoveNext 'Move to the next Record
Loop
End With
rst.Close
Set rst = Nothing
Set qdf = Nothing
Set db = Nothing
End Function
There are 2 records in my test table/query. Unfortunately, this code produces the first record twice and does not show the second record when I close the form after the first record has displayed.
The form is set to dialogue.
It seems that the code is looping back to the first record at all times.
Sorry, but what am I doing wrong here?
Appreciate your assistance.
David
I am new to coding.
I am trying to loop through a query that will show a form that reminds the user to follow up an event from last year.
My code is:
Public Function EventReminder()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("qryEventFollowUp")
Set rst = qdf.OpenRecordset()
With rst
Do Until .EOF
DoCmd.OpenForm FormName:="frmMessageBoxEventFollowUpEdit", WindowMode:=acDialog
.MoveNext 'Move to the next Record
Loop
End With
rst.Close
Set rst = Nothing
Set qdf = Nothing
Set db = Nothing
End Function
There are 2 records in my test table/query. Unfortunately, this code produces the first record twice and does not show the second record when I close the form after the first record has displayed.
The form is set to dialogue.
It seems that the code is looping back to the first record at all times.
Sorry, but what am I doing wrong here?
Appreciate your assistance.
David