Hi. I have a command button that will "approve" all records currently being looked at by an "approver". For some reason, even though there are multiple records that exist in the recordsetclone, EOF is returning true. I think this may have something to do with the sort order of the underlying query, but I'm not sure; at any rate, I don't want to change the sort order. I thought you had to check for BOF and EOF, or at least EOF before doing any recordset "Move" type commands. If I stop the code after declaring the recordset and do a recordcount, it says that there are records in the recordset, but no looping occurs because EOF returns True.
I don't get it. I would appreciate any help. Here is the code behind the command button.
Expand|Select|Wrap|Line Numbers
- Private Sub cmdApproveAll_Click()
- Dim db As DAO.database
- Dim rs As DAO.Recordset
- Set db = CurrentDb
- Set rs = Me.Child.Form.RecordsetClone
- With rs
- If Not .BOF And Not .EOF Then
- .MoveFirst
- Do Until .EOF = True
- If .Fields("New") = True Then
- .Edit
- .Fields("Approved") = True
- .Fields("Approver") = CurrentUser()
- .Fields("AppDenDate") = Now()
- .Fields("Denied") = False
- .Update
- .MoveNext
- Else
- .MoveNext
- End If
- Loop
- Else
- End If
- End With
- rs.Close
- Set rs = Nothing
- Set db = Nothing
- Me.Requery
- End Sub