Loop not executing properly

G

Guest

The code below is part of a race timing program in Access 2000.
The loops below are designed to post an overall "place" value for all race
participants of a certain gender (in this case - female), regardless of age
categories, etc. (i.e., 1st female, 2nd female, 3rd female, etc.) The code
retrieves the race bib # from the first record in the linked query
"qryLinkTime&Bib&RaceData2Mile(Female)" and then finds the same race bib # in
tblRaceData and adds a "1" in the fldPlace. Then it should go back to the
linked query, find the second record, retrieve the race bib#, and attach a
strPlace of "2" to the same race bib# in tblRaceData. . . and so on.

Lately the program has been acting erratic and not posting proper placings
or not entering fldPlace at all for certain records. I'm not sure what
changed. Perhaps someone can spot the breakdown in the loops? Or possibly
someone has a more elegant way to accomplish the same task?

Rick Mitchell
Springville, CA

'Adds "Place" for 2 Mile Females
Set rec = db.openrecordset("qryLinkTime&Bib&RaceData2Mile(Female)")
rec.MoveFirst
strPlace = 0
Do Until rec.EOF() = True
strBib = rec("fldBib")
strPlace = strPlace + 1
Set rec = db.openrecordset("tblRaceData")
rec.MoveFirst
Do Until rec.EOF = True
If rec("fldBib") = strBib Then
rec.edit
rec("fldPlace") = strPlace
rec.Update
GoTo LabelPlace2
End If
rec.MoveNext
Loop
LabelPlace2:
Set rec = db.openrecordset("qryLinkTime&Bib&RaceData2Mile(Female)")
rec.MoveFirst
Do Until rec.EOF() = True
If rec.RecordCount = strPlace Then
rec.MoveNext
GoTo LabelNumber2
End If
rec.MoveNext
Loop
LabelNumber2:
Loop
 
J

J. Goddard

You need two separate recordsets - you are resetting the rec recordset
inside the loop - small wonder the behaviour is "erratic"!

John
 

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

Similar Threads


Top