View Full Version : EOF and BOF not co-operating


ions
01-23-2008, 11:40 AM
Dear Access Expert

The following code marked 'BREAKS DOWN!!! INCORRECT is giving me problems.



Forms(FormName).ExclusionDaysANDFlights.Requery
Set rcdSet = Forms(FormName).ExclusionDaysANDFlights.Form.Recor dsetClone

'BREAKS DOWN!!! INCORRECT
If rcdSet.EOF And rcdSet.BOF Then
Exit Function
End If

rcdSet.MoveFirst 'It's a recordset Clone so make sure you start from the top.



It appears Access Jet is not updating the EOF and BOF attributes as I change the recordsetClone. If there is a record in the RecordSetCLone EOF and BOF sometimes remain TRUE... which indicates an empty recordSet. Sometimes if the record set is EMpty EOF will be False but BOF will be True.

What is happening here? Some Access quirk?

For example

Zaeed
01-23-2008, 02:44 PM
I use that same line of code and have never had a problem with it...

The only difference is I put

If rst.EOF = True And rst.BOF = True Then Exit Function

dunno if that would affect it or not..

jdraw
01-23-2008, 07:41 PM
Dear Access Expert

The following code marked 'BREAKS DOWN!!! INCORRECT is giving me problems.



Forms(FormName).ExclusionDaysANDFlights.Requery
Set rcdSet = Forms(FormName).ExclusionDaysANDFlights.Form.Recor dsetClone

'BREAKS DOWN!!! INCORRECT
If rcdSet.EOF And rcdSet.BOF Then
Exit Function
End If

rcdSet.MoveFirst 'It's a recordset Clone so make sure you start from the top.



It appears Access Jet is not updating the EOF and BOF attributes as I change the recordsetClone. If there is a record in the RecordSetCLone EOF and BOF sometimes remain TRUE... which indicates an empty recordSet. Sometimes if the record set is EMpty EOF will be False but BOF will be True.

What is happening here? Some Access quirk?

For example

In many examples, especially when using RecordCount, people will
rst.Movelast, then rst.MoveFirst before checking that .RecordCount is meaningful or that .Eof and .Bof are true. It may be a quirk related to when Access/Jet updates this values.

ions
01-24-2008, 12:19 AM
yes it appears that the EOF and BOF are not getting refreshed properly. The previous values are being used.

Zaeed
01-24-2008, 12:43 PM
can you maybe put rcdSet.requery before the check?