Formatting a Txtbox to Display Time

J

John C.

I have a field for Date/Time.

I have tried formatting the field to hh:nn (no quotes) but
it defaults back to Short Time (which only displays h:nn).

I have tried using "hh:nn" (with quotes), but then all
that is displayed is just that, hh:nn (no quotes).

I have tried changing this field to a text, same thing
occurs.

I would like to have "01:30" (no quotes) displayed.
Basically, military time is needed.

Thankyou in advance. Hope everyone has recovered from New
Years.
 
M

Marshall Barton

John said:
I have a field for Date/Time.

I have tried formatting the field to hh:nn (no quotes) but
it defaults back to Short Time (which only displays h:nn).

I have tried using "hh:nn" (with quotes), but then all
that is displayed is just that, hh:nn (no quotes).

I have tried changing this field to a text, same thing
occurs.

I would like to have "01:30" (no quotes) displayed.
Basically, military time is needed.


Irritating isn't it. If this is an editable text box,
fixing it is kind of messy. Place another text box of the
same size exactly on top of the current text box (use Format
- Bring to Front if needed). Set this new text box's
Control Source expression to:
=Format(originaltextbox, "hh:nn")

Now, use code in the new text box's GotFocus event to reset
the focus to the original text box.
originaltextbox.SetFocus

If users can not enter the time, then just use the format
function:
=Format(dtfield, "hh:nn")
 

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