Thanks both but I am still having problems..
When I set the field format to hh:nn:ss and the input mask to 99:99:00 it
seems to display and store the time in hours, minutes and seconds.
I have set the properties on the form to match the table but the value
returned afte data is entered shows am or pm....
What I need to do is the user enters a starting time and an ending time and
I need to calculate the average speed. Below is the code I have been working
with. I started with only hours and minutes input from the user and am trying
to change to the hh:mm:ss. The code works until I get to the seconds part:
Private Sub Time_Exit(Cancel As Integer)
Dim MyETime, MyEMinute, MyEhour, MyESeconds, ETotlTime
MyETime = Me.Time
If [OdometerEnd] = "0" Or [OdometerEnd] = "" Then
[Route#].SetFocus
Else
'Assign a time
MyEhour = Hour(MyETime) 'MyEHour contains hours
MyEMinute = Minute(MyETime) 'MyEMinute contains minutes
MyESeconds = Seconds(MyTime) 'MyESeconds contains seconds
ETotlTime = (MyEhour * 60) + (MyEMinute * 60) + MyESeconds
Me!ETAveSpeed = ([Mileage] / ETotlTime) * 360
[RideTime].SetFocus
End If
End Sub
I get the error at the MyESeconds =
Debugging MyEtime at line 3 shows hh:mm:ss with am/pm
> Oops. Sprinks is correct....it's Long Time, not Short Time.
>
[quoted text clipped - 7 lines]
> >>
> >> Thank you.
If I am reading your question correctly...
You said you want to store a TIME, not a DURATION. They are two different
things.
TIME is a specific point in time (1 o'clock, January 15). TIME in this case
would never be greater than 24:00:00.
DURATION is a length of time spent on a task, or time remaining until an
event. This could be any number and can be greater than 24 hours. The key
here is that this is a NUMBER, not a TIME. Once you do your calculation,
you will get the results in elapses seconds and you can do the division to
break it out into hours, minutes, and seconds. 1,000 seconds equals 16
minutes, 40 seconds, for example.
Hope that helps,
Rick B
> Thanks both but I am still having problems..
> When I set the field format to hh:nn:ss and the input mask to 99:99:00 it
[quoted text clipped - 42 lines]
> > >>
> > >> Thank you.
Wylie C - 31 Jan 2005 22:31 GMT
Rick,
I know I should be getting this but I am not. I have changed the field in
the table to Number, single. Input mask 99:99:00 and the same on the form.
When I run the code, the time stored in the table has no formatting to
separate the hrs, min, sec. If I enter 01:00:00 the number the code reads is
10000. How can I store the value in the table as hh:nn:ss?
> If I am reading your question correctly...
>
[quoted text clipped - 67 lines]
> > > >>
> > > >> Thank you.
Rick B - 31 Jan 2005 23:13 GMT
You can't. It is stored as seconds. To format it, you will have to do some
math.
Here is an example of storing minutes as hours and minutes. In other words,
120 would display 2:00.
You will have to modify it and place it in an unbound field on your form or
report...
=[SomeFieldName]\60 & Format([SomeFieldName] Mod 60, "\:00")
Hope that helps.
Rick B
> Rick,
> I know I should be getting this but I am not. I have changed the field in
[quoted text clipped - 74 lines]
> > > > >>
> > > > >> Thank you.