Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do Until Loop

Status
Not open for further replies.

stevie1under

Technical User
Mar 2, 2002
2
CA
hey,

i have the following code that won't loop ...
anyone see the problem?

Private Sub Form_Current()
Dim rSt As DAO.Recordset
Set rSt = Me.Recordset
Dim int2Count As Integer
int2Count = rSt.RecordCount

If int2Count = 0 Then Exit Sub

rSt.MoveFirst

Do Until rSt.EOF = True
subChangeBackColor
rSt.MoveNext
Loop

End Sub


thanks
steve
 
Well, if rSt.RecordCount = 1 then it won't loop. And that is the default value of recordsets in order to save time. Before you rSt.MoveFirst try a rSt.MoveLast to update the RecordCount.

...
If int2Count = 0 Then Exit Sub

rSt.MoveLast
rSt.MoveFirst
'now rSt.RecordCount will be the actual count
...

"The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
Thanks very much ... that helped me figure out a coupld of things!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top