Time Comparison
Greetings.
I've written a form that allows users to take a timestamp in
HH:mm:ss format and then insert it, in correct order, into a list
of other timestamps.
In order to insert the timestamp in its correct order, I loop
over the list until I find a value greater than the value of my
timestamp. I then insert a new row and place my timestamp
in the row I just created.
My problem is that I can't get my time comparison to work
properly. Here is how I attempt to do the comparison:
For i = 2 To LastRow
If CDate(EventTimer.EventClock.Value) CDate(Sheet2.Cells(i, 3).Value)
Then
Sheet2.Rows(i).Insert
Sheet2.Cells(i, 1) = i - 1
Sheet2.Cells(i, 3) = EventTimer.InputTime
'Increment places on the remaining rows.
For j = (i + 1) To (LastRow + 1)
Sheet2.Cells(j, 1) = j - 1
Next j
EventTimer.PlaceList.RowSource = EventTimer.PlaceList.RowSource
Exit Sub
End If
Next i
My row is always inserted at the top of the list, even though I know
the value entered into the EventClock field of the EventTimer form
is greater than the first item on the list.
Somehow the If statement where I compare the times just isn't
working.
What's wrong with my comparison? Do I need to bracket the times
with the # characters, as I've done before programming Acess?
Do I need to somehow better massage the contents of the EventClock
field or the Cells that I am comparing this against?
Respectfully,
Charles
|