Text box to enter time duration h:nn:ss

J

joan

Greetings,

I have read several entries regarding the problem of working with elapsed
time in access but have not found a solution that I understand how to
implement.

In brief, my situation is something like this:

Tbl_Racetime
Field1 ID (autonumber)
Swimtime (integer stored as seconds)
Runtime (integer stored as seconds)
Biketime (integer stored as seconds)

I need to create a form in which the user would enter the times in h:nn:ss
format but the data would be converted and stored as number of seconds. This
is so the data can be used in calculations.

Conversely, I would need to convert the data from seconds to h:nn:ss for use
in reports.

Is there code that I could cut and paste somewhere in the properties of the
form?
Or is there a query that needs to created?

My feeble grasp on Access is not enough to wrestle with this on my own and
my brain is about to explode! Any help appreciated.

joan
 
J

joan

Thanks for trying Daniel but none of the posts seemed to address my problem.
At least not as far as can tell. I think I am looking for a step 1, step 2,
step 3 answer. ......ACCESS for DUMMIES type of help.
My table data will not be a point in time but rather a duration (how long it
took to finish a race). I know that access does not work with that concept
and needs to be worked around. However, the user will need to input the data
(on form) as h:nn:ss. If I didn't need to do some calculations I would just
store the data as text but there will be a need to sort, total, etc. This
being the case I thought there might be a way to enter the duration in the
h:nn:ss format but have it converted to a number value representing seconds
in the table and also a method to reverse the problem and show the seconds
value represented as hh:nn:ss.
 
L

Linq Adams via AccessMonster.com

This Function 'Parses seconds into Hours-Minutes-Seconds in HH:MM:SS format.
Place it in a standard module (if you use a new module, DO NOT NAME IT
**TimeParsing** as this will confuse Access!) and call it like

YourParsedTimeField = TimeParsing(TotalSeconds)

'********************** Code **************************
Public Function TimeParsing(TotalSeconds As Long) As String

Dim HoursLapsed, SecondsLeft, MinutesLapsed, SecondsLapsed As Long

HoursLapsed = Int(TotalSeconds / 3600)

SecondsLeft = TotalSeconds Mod 3600

MinutesLapsed = Int(SecondsLeft / 60)

SecondsLapsed = SecondsLeft Mod 60

TimeParsing = Format(HoursLapsed, "00") & ":" & Format(MinutesLapsed, "00") &
":" & Format(SecondsLapsed, "00")

End Function
 
J

joan

Thank you very much for your assistance. Your sample db looks like it will
help me out greatly!
 
D

Douglas J. Steele

<picky>
That function formats seconds into hh:mm:ss. It does not parse.
</picky>
 

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