Too simple formatting question

A

Audrey

Hi,
I'm almost ashamed of having to ask this here, but the
Access help doesn't help and I'm out of options.
I want to format a field so I input a number of hours such
as

40:00
7:45
8:30

It's a number of hours, not an hour, so I can't use the
automatic time/date formatting (unless there is a weird
setting I'm not aware of).

Help?
 
H

Hugh O'Neill

Audrey said:
Hi,
I'm almost ashamed of having to ask this here, but the
Access help doesn't help and I'm out of options.
I want to format a field so I input a number of hours such
as

40:00
7:45
8:30

It's a number of hours, not an hour, so I can't use the
automatic time/date formatting (unless there is a weird
setting I'm not aware of).

Help?


You can input the hours and minutes in separate textboxes and treat the
input values as simple integers. Store them that way as well. Do the
maths on the values whenever you need to.

hth

Hugh
 
J

John Vinson

Hi,
I'm almost ashamed of having to ask this here, but the
Access help doesn't help and I'm out of options.
I want to format a field so I input a number of hours such
as

40:00
7:45
8:30

It's a number of hours, not an hour, so I can't use the
automatic time/date formatting (unless there is a weird
setting I'm not aware of).

Probably not as simple as it seems: hours and minutes use base 60, and
computers generally don't! There are a couple of choices. One would be
to use a Text field with an input mask such as !90:00 (requiring entry
of three to four digits and automatically filling in the colon), but
you won't be easily able to do calculations with the value.

An alternative (what I'd recommend) is that you store the duration in
a long integer field of minutes - e.g. 40:00 would be stored in your
table as 2400. You can *display* this as hours and minutes using an
expression like

[Duration] \ 60 & Format([Duration] MOD 60, ":00")

For data entry you'ld need to use an unbound textbox and use a bit of
VBA code to parse the entry into a number of minutes.
 
A

Audrey

You're absolutely right, of course.

I don't need to do any calculations on the fields, but I'd
feel bad designing something that I can't upgrade easily
in the future, so I'd better allow for calculations.

Thanks!
 
A

Audrey

Hi again,
I don't know if you're still reading this, but I need a
little nudge to go forward.
You can *display* this as hours and minutes using an
expression like
[Duration] / 60 & Format([Duration] MOD 60; ":00")

Where should I put this? It works in the "control source"
of the Properties, but of course if I do that I can't
update the field. It's not an event, so I'm a little
confused what VB code I could be using...
For data entry you'ld need to use an unbound textbox and use a bit of
VBA code to parse the entry into a number of minutes.

Again... what should I do exactly? Put it on the onChange
event? Or the LoseFocus? Then, once I've got the value, do
I need to get my recordset, find the current value and put
the parsed value in there, or is there a more simple
method?

Thanks again
 

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