Cipher via AccessMonster.com said:
Is the following, the best way to detect an EOF condition?
Boolean_State=True
Do While Boolean_State
Set rs = New ADODB.Recordset
StrOne = "SELECT * FROM Inject_Cycle " & "WHERE ID=" &
Record_Number
rs.Open StrOne, CurrentProject.Connection, adOpenForwardOnly,
adLockReadOnly
If rs.EOF Then
Boolean_State=False
GoTo End
End If
What are you actually trying to do? If you just want to know if the
recordset you just opened is empty, all you have to do is check either its
EOF property or its BOF property, as both will be True. You don't need to
check both properties if you just opened the recordset yourself. If you
were passed a recordset in unknown state, not necessarily freshly opened,
then you should check both properties ("If rs.EOF And rs.BOF Then") to
verify that it's an emtpty recordset.
EOF is a boolean property, so I don't know why your example goes to the
trouble of defining and setting a boolean variable, unless there are other
conditions that may set that variable. But then, I don't know whether you
really want to be creating and opening the recordset inside the loop,
either. If your loop is just supposed to be looping through all the records
in the recordset, you ought to be opening the recordset outside the loop.
But if this recordset is just one of several you'll be processing inside
your loop, then maybe that's right. You really haven't given us enough
information about your intentions.