Automatically assign Ranking based on Time taken

G

Guest

I have a form where a time is entered in seconds in each row ie 103.36 102.23
etc. Also in that form I have a position filed, what I am trying to do is for
some code to scroll thru the form and assign a ranking to each record based
on the number of seconds. Ie the lowest would be 1 and so on. Does anyone
have any idea how this would be done

Thanks
 
M

Marshall Barton

Nigel said:
I have a form where a time is entered in seconds in each row ie 103.36 102.23
etc. Also in that form I have a position filed, what I am trying to do is for
some code to scroll thru the form and assign a ranking to each record based
on the number of seconds. Ie the lowest would be 1 and so on. Does anyone
have any idea how this would be done


This is relatively easy to do using a query with a subquery:

SELECT T.person,
(SELECT Count(*)
FROM thetable As X
WHERE X.seconds <= T.seconds
) As Position
FROM thetable As T

But it would take a sort algorithm operating on the form's
recordset to do it in code. If you use a query like the
above as the form's record source, then the only code you
would need is
Me.Requery
whenever you want to display the new positions after
entering/editing some time values.
 
G

Guest

OK I am halfway there

I have the record number now I need to be able to click an button on the
form and have it loop thru each record on the form and place the value from a
field called rownum into a field called position. Once it reaches the last
record stop
 

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