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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SORT & UPDATE RECORDSET

Status
Not open for further replies.

LBERNARDE

Programmer
Mar 14, 2001
21
US
I have a recordset that I'm trying to sort in descending order, then according to a loop I've designed move thru the top 1-3 and assign a position. Ex 10 competitors 2 positions etc. However what is happening is the first time I go thru the loop it updates the correct record, but it stays on the same record each time? I've tried adding bookmark to make sure I'm on the correct record. Not really sure what I'm doing wrong. Any advice would be appreciated.
Thanks Lisa

'Sub ProneAwards(rstclass2 As Recordset)

proneawards:
With rstclass2
.MoveLast
strreccount = rstclass2.recordcount
.MoveFirst
End With

If strreccount <= 5 Then
mplace = 1
If strreccount > 5 And strreccount <= 10 Then
mplace = 2
If strreccount > 10 Then
mplace = 3
End If
End If
End If

mplacecounter = 0
Do
Do While mplacecounter <= mplace
mplacecounter = mplacecounter + 1
STRSORTON = &quot;PRONEMMA&quot;
'With rstClass2
rstclass2.Sort = STRSORTON
rstclass2.MoveFirst
VARBOOKMARK = rstclass2.Bookmark
If mplacecounter = 1 Then
rstclass2.Bookmark = VARBOOKMARK
rstclass2.Edit
rstclass2!proneaward = &quot;1st Prone&quot;
rstclass2.Update
rstclass2.MoveNext
VARBOOKMARK = rstclass2.Bookmark
mplacecounter = mplacecounter + 1
Else
If mplacecounter = 2 Then
rstclass2.Bookmark = VARBOOKMARK
rstclass2.Edit
rstclass2!proneaward = &quot;2nd Prone&quot;
rstclass2.Update
rstclass2.MoveNext
VARBOOKMARK = rstclass2.Bookmark
mplacecounter = mplacecounter + 1
Else
If mplacecounter = 3 Then
rstclass2.Bookmark = VARBOOKMARK
rstclass2.Edit
rstclass2!proneaward = &quot;3rd Prone&quot;
rstclass2.Update
rstclass2.MoveNext
VARBOOKMARK = RSTLCASS2.Bookmark
mplacecounter = mplacecounter + 1
End If
End If
End If
Loop
Loop Until mplacecounter >= mplace
 
I want to assign awards and update a table. How the heck do I do this? The code below is updating the table, however, it updates the same record every time. Is there something wrong with my sort? How can I get the code to know which record to update in the table. I've been stuck on this for some time, so if anyone has any ideas, I'd appreciate it.

Thanks Lisa

'Sub ProneAwards(rstclass2 As Recordset)

proneawards:
With rstclass2
.MoveLast
strreccount = rstclass2.recordcount
.MoveFirst
End With

If strreccount <= 5 Then
mplace = 1
If strreccount > 5 And strreccount <= 10 Then
mplace = 2
If strreccount > 10 Then
mplace = 3
End If
End If
End If

mplacecounter = 0
Do
Do While mplacecounter <= mplace
mplacecounter = mplacecounter + 1
STRSORTON = &quot;PRONEMMA&quot;
'With rstClass2
rstclass2.Sort = STRSORTON
rstclass2.MoveFirst
VARBOOKMARK = rstclass2.Bookmark
If mplacecounter = 1 Then
rstclass2.Bookmark = VARBOOKMARK
rstclass2.Edit
rstclass2!proneaward = &quot;1st Prone&quot;
rstclass2.Update
rstclass2.MoveNext
VARBOOKMARK = rstclass2.Bookmark
mplacecounter = mplacecounter + 1
Else
If mplacecounter = 2 Then
rstclass2.Bookmark = VARBOOKMARK
rstclass2.Edit
rstclass2!proneaward = &quot;2nd Prone&quot;
rstclass2.Update
rstclass2.MoveNext
VARBOOKMARK = rstclass2.Bookmark
mplacecounter = mplacecounter + 1
Else
If mplacecounter = 3 Then
rstclass2.Bookmark = VARBOOKMARK
rstclass2.Edit
rstclass2!proneaward = &quot;3rd Prone&quot;
rstclass2.Update
rstclass2.MoveNext
VARBOOKMARK = RSTLCASS2.Bookmark
mplacecounter = mplacecounter + 1
End If
End If
End If
Loop
Loop Until mplacecounter >= mplace
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top