Link to home
Start Free TrialLog in
Avatar of frimy
frimyFlag for United States of America

asked on

Calculate Time acces 2010

Hello All,
I want to calculate time from Start and End, Minutes and Hours no seconds.
I setup the controls as, Format = Medium Time, Input Mask = 99:00\ >LL;0;_
But I'm having a hard time to add and change the time ie.1:1 AM,
i always have to enter the full time ie. 01:01 AM, even i just want to change ie. minutes only (i always get the in correct input mask message)
Is there a easier way to set the time fields?
Thanks in advance
Avatar of PatHartman
PatHartman
Flag of United States of America image

Input masks don't really ensure valid data and in the case of dates and times, they interfere and cause usability issues.  Rather than using an input mask, open the properties dialog for the control and on the Format tab, chose Short time for the Format property.

Keep in mind that datetime fields always include both date and time and don't represent elapsed time.  They represent a point in time which is different.  You might actually find it easier to use two separate numeric fields.  One for hours and one for minutes with a colon label between them.  Of course, to do the calculations, you will need to convert hours to minutes, subtract the totals and then convert back to hours and minutes.
Avatar of frimy

ASKER

I also need also the AM and PM
is there an alternative to using the Input mask?
If you want AM/PM, then use the medium date format.
by default if you omit AM/PM its AM, I had somewhere where I wrote code that if time is between so & so then convert it to PM, so user didnt had to enter that.
It is a surprisingly difficult task. You may study this article:

Entering 24-hour time with input mask and full validation in Microsoft Access

It covers what you call "Military Time", but you may be able to adjust it to accommodate a 12-hour input only.
Then I would add a checkbox for marking PM or a combobox where you can select AM or PM. In both cases, use

    DateAdd("h", 12, .Value)

to obtain the 24-hour time value of the PM time.

/gustav
Avatar of frimy

ASKER

Thanks for your help.

I don't have problem with calculating the time.
I only need to simplify the entering or alter the time.
I use the Input mask 99:00\ >LL;0;_ from access wizard it works fine.
But it gets frustrating when you change the time i.e. changing the hour from 1 to 2 and not using 01 or AM to PM and not adding a space before and so on.
The only way to eliminate problems is to highlight the whole control and enter it again.

Is there a simple easy to use Input task?
Thanks again
My demo in the referred article covers this "issue".
You'll see I use a quite different input mask for this reason.

/gustav
Avatar of frimy

ASKER

it looks very good,
but if the hour is only 1 digit and I want to change the hour, I have to retype the hours and minutes.
Also what about AM and FM
input masks are inflexible.  either train people to understand that or create 3 separate controls - hours, minutes, AM/PM.
Also what about AM and FM
did you tried my suggestion? it works for me pretty well.
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of frimy

ASKER

Thanks Gustav,
I didn't have time now to explore your techniques.
I will see how to implement it to my system.