How to test for EOF

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...
 
M

Marshall Barton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top