Don't get EOF when I expect it!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to execute some code in an Access 2000 database when, while
scrolling through a subform using my mouse wheel, I reach the end of the DAO
recordset. Data Additions are allowed in this subform. The following code
fragment indicates how I am trying to do this. However, to my surprise, the
EOF condition is not satisfied when I scroll beyond the last record.

Any clarification or assistance would be much appreciated.

Set rst = Me.RecordsetClone
With rst
If .EOF = True Then
Some code ......
Else
Some other code ...
End If
End With
 
Your problem may be the use of the RecordsetClone instead of the Recordset.
The RecordsetClone is a copy of the original recordset, but may not be
"synchronized" at all times with which record is "active". Try using
Recordset in your code.
 
Thanks for the suggestion, Ken. I've never messed with the actual form
recordset before, but I gave it a try. Unfortunately, I'm now getting obscure
errors that close down Access. Stepping through my code one line at a time
works the first time around but then it fails with Error 91 the second time
it executes this line of code (stored in the Form's Current Event):

If .EOF = True and .BOF = True Then

Are there some traps for the unwary when using the actual recordset for a
form rather than the clone?
 
Working with the form's Recordset can be a bit tricky if you move from one
record to another. The error 91 suggests that the object variable that you
were using is not set to anything at that time. I'd have to see all your
code to give specific suggestions.

--

Ken Snell
<MS ACCESS MVP>

David Anderson said:
Thanks for the suggestion, Ken. I've never messed with the actual form
recordset before, but I gave it a try. Unfortunately, I'm now getting
obscure
errors that close down Access. Stepping through my code one line at a time
works the first time around but then it fails with Error 91 the second
time
it executes this line of code (stored in the Form's Current Event):

If .EOF = True and .BOF = True Then

Are there some traps for the unwary when using the actual recordset for a
form rather than the clone?
 
David Anderson said:
I would like to execute some code in an Access 2000 database when,
while scrolling through a subform using my mouse wheel, I reach the
end of the DAO recordset. Data Additions are allowed in this subform.
The following code fragment indicates how I am trying to do this.
However, to my surprise, the EOF condition is not satisfied when I
scroll beyond the last record.

Any clarification or assistance would be much appreciated.

Set rst = Me.RecordsetClone
With rst
If .EOF = True Then
Some code ......
Else
Some other code ...
End If
End With

It might be simpler to use the form's Current event to check whether
Me.NewRecord is True.
 
Hey, I didn't know about that one. It works fine (i.e. I've now moved on to
the next bug in my code!). Thanks, Dirk.
 
Back
Top