How to test for EOF

  • Thread starter Thread starter Dale
  • Start date Start date
D

Dale

Following the advice from this newsgroup I am trying to test for EOF in the
rstEncounters, I've tried a couple of things, adding another loop statement
which didn't work and an "If" statements in different locations within the
code.
This also didn't work...so I'm at a bit of loss as to how to follow through
on this suggestion.

The code does run if I replace "=" with "<>" in the second loop..does that
mean
the code is optimal?

other code....

Do While Not rstPatients.EOF
lngCount = 1
Do While rstPatients!Patsys = rstEncounters!Patsys
With rstEncounters
.Edit
!encnum = lngCount
.Update
.MoveNext
lngCount = lngCount + 1
Debug.Print lngCount
End With
Loop
rstPatients.MoveNext
Loop

other code...
 
Dale said:
Following the advice from this newsgroup I am trying to test for EOF in the
rstEncounters, I've tried a couple of things, adding another loop statement
which didn't work and an "If" statements in different locations within the
code.
This also didn't work...so I'm at a bit of loss as to how to follow through
on this suggestion.

The code does run if I replace "=" with "<>" in the second loop..does that
mean
the code is optimal?

other code....

Do While Not rstPatients.EOF
lngCount = 1
Do While rstPatients!Patsys = rstEncounters!Patsys
With rstEncounters
.Edit
!encnum = lngCount
.Update
.MoveNext
lngCount = lngCount + 1
Debug.Print lngCount
End With
Loop
rstPatients.MoveNext
Loop


How about adding;
If .EOF Then Exit Do
right after the MoveNext?

But that won't catch the case when there are no matching
records in rstEncounters. If that's possible, then try
something like this:

With rstEncounters
Do Until .EOF
If rstPatients!Patsys <> !Patsys Then Exit Do
.Edit
!encnum = lngCount
.Update
.MoveNext
lngCount = lngCount + 1
Debug.Print lngCount
Loop
End With
 
Back
Top