EOF is not being recognized in recordset?

candyA25

New member
Local time
Today, 17:54
Joined
Jun 26, 2013
Messages
9
I have a form with a query set up as the record source. If there are records in this query, the form will display. When the user clicks a button, if there is another record in this query, the form displays the next record. When it gets to the EOF, it should close this form, but EOF is not being recognized (I run debug and it says it's false when the button is clicked)? I get run-time error '3201' after I click the button twice.

I know for a fact that there are 2 records in this query. So once I click the button on the 2nd record, the form should close.

Code:
Private Sub SelectTblMyMedButton_Click()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    
    Set db = CurrentDb()
    Set rs = db.OpenRecordset("qryMedDataSelect", dbOpenDynaset)
    
    If Not (rs.EOF And rs.BOF) Then
        Me.Form.Recordset.MoveNext
        rs.MoveNext
    Else
        Set rs = Nothing
        DoCmd.Close acForm, "frmMedDataSelect", acSaveNo
        'call sync module
        SyncDataSwine
    End If
End Sub
 
You are opening the query each time you click the button... always at record 1, you can move to the second record 1 million times and sstill be at record 1....

Look into "Me.Recordsetclone"
 
Because your intended criterion (as described in the title of your post) is not the criterion you put into your code. The criterion in your code fails of course.
 

Users who are viewing this thread

Back
Top Bottom