Code Problems

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hey, I came across a problem and I was wondering if you
could help me. I have a form with 8 competitors' names &
times after a swimming race. I want to compare each time
and display the quickest time.

So far I have got 8 fields of times all formatted in long-
time format. I have another field called overall best
time. I need to compare the times and display the
quickest in overall best time.

This is the code so far - but dont think I'm correct:

Me![OverallBest] = Me![Entrant1Time]
If Me![Entrant2Time] < Me![OverallBest] Then Me!
[OverallBest] = Me![Entrant1Time]

What this idea was meant to do, was to put the first time
in the overall best time, then compare it with the
second. If the second was smaller than the overall best,
then it would be replaced
YEH - I KNOW IVE MADE A MESS OF IT

Any help would be greatly appreciated.

If you need to see it, U can always reach me via MSN
messenger and Remote assistance.
MSN Address is (e-mail address removed)

Thankx Again!

Paul
 
Paul,

Looks to me like it should be...
Me![OverallBest] = Me![Entrant1Time]
If Me![Entrant2Time] < Me![OverallBest] Then
Me![OverallBest] = Me![Entrant2Time]
End If

To do it for all 8 competitors, you could do something like...
Dim i As Integer
Me![OverallBest] = Me![Entrant1Time]
For i = 2 to 8
If Me("Entrant" & i & "Time") < Me.OverallBest Then
Me.OverallBest = Me("Entrant" & i & "Time")
End If
Loop

When you say "I KNOW IVE MADE A MESS OF IT", I presume you mean that
you realise that this data should be separate records rather than
separate fields?

- Steve Schapel, Microsoft Access MVP
 
Back
Top