Time function

  • Thread starter Thread starter Susanne
  • Start date Start date
S

Susanne

I need to display in formation in military time. hh:nn, ie, short time. I do
not want the text box to change to "normal" view when the field is entered ,
with AM / PM showing. No matter what I do, it still displays with 03:46:01
PM when the field is entered. Help?
 
Susanne said:
I need to display in formation in military time. hh:nn, ie, short time. I do
not want the text box to change to "normal" view when the field is entered ,
with AM / PM showing. No matter what I do, it still displays with 03:46:01
PM when the field is entered. Help?


If the field's data type is Date/Time, just set the text
box's Format property to
hh:nn:ss
 
That's what I originally did, and it worked, but we only want to see the hour
and minute. I may need to just set it at that. The problem arises if the
data is manually entered, therefore overr-riding the preset time.

Thanks!
 
If you don't want to see the seconds, set the Format
property to:
hh:nn

I don't understand the problem with users entering a time.
AFAIK, that should not be an issue.
 
That's what I originally did, and it worked, but we only want to see the hour
and minute. I may need to just set it at that. The problem arises if the
data is manually entered, therefore overr-riding the preset time.

You can use a Format of hh:nn to display existing data, and an Input Mask of
00:00 to force entry of just the four digits.
 
I got it to work, before your comment ... it is not easy overriding presets
in Access. I would do that, that is, set it to hh:nn, then it would
automatically change the properties to the field to short date (the hh:nn
disappeared) and also the input mask. Appearance wise it would display fine,
but enter the field and it botches what I wanted.

The only way I got everything to work correctly was in VBA to set the field
= Format(Time, "hh:nn"). Access then didn't mess around with the layout and
change it when you enter the field into the date format with AM or PM.

Marshall Barton said:
If you don't want to see the seconds, set the Format
property to:
hh:nn

I don't understand the problem with users entering a time.
AFAIK, that should not be an issue.
--
Marsh
MVP [MS Access]

That's what I originally did, and it worked, but we only want to see the hour
and minute. I may need to just set it at that. The problem arises if the
data is manually entered, therefore overr-riding the preset time.
 
I still don't understand what you mean by "presets". Maybe
you mean the default property settings? If so, you can just
replace whatever Access put in with whatever you want.
OTOH, using an input mask can override all kinds of things
(one reason why I never use input masks). First thing I
would do is remove the input mask and see where you stand,
before beating your head against the wall trying to overcome
the idiosyncracies of input masks.

Where/what did you set the Format property? It should be
the form text box, not a query or table field.

What you did using the Format function may(?) not be a good
fix because Format always returns a string value, not a time
value.
 
I was wondering about that (the string value). I mainly just need the values
to get a total time (houre:minute) in a calculation. What I mean by presets
is the default settings for lack of a better word at the time I was typing
(looking at something that you know is taking too long and getting frustrated
because it should be simple). I got even more frustrated having to change
the 9+ fields everytime I made changes.

Oh, and yes, I was setting it up in the form. A button would be pressed to
enter the current "time" then when the second button was pressed to enter the
end time, it would also calculate the total time for the 3rd field.

I thank everyone for your suggestions and I will see if I can make it work
the more simple way without having the field value change on me when the
field is entered.

Marshall Barton said:
I still don't understand what you mean by "presets". Maybe
you mean the default property settings? If so, you can just
replace whatever Access put in with whatever you want.
OTOH, using an input mask can override all kinds of things
(one reason why I never use input masks). First thing I
would do is remove the input mask and see where you stand,
before beating your head against the wall trying to overcome
the idiosyncracies of input masks.

Where/what did you set the Format property? It should be
the form text box, not a query or table field.

What you did using the Format function may(?) not be a good
fix because Format always returns a string value, not a time
value.
--
Marsh
MVP [MS Access]

I got it to work, before your comment ... it is not easy overriding presets
in Access. I would do that, that is, set it to hh:nn, then it would
automatically change the properties to the field to short date (the hh:nn
disappeared) and also the input mask. Appearance wise it would display fine,
but enter the field and it botches what I wanted.

The only way I got everything to work correctly was in VBA to set the field
= Format(Time, "hh:nn"). Access then didn't mess around with the layout and
change it when you enter the field into the date format with AM or PM.
 
Back
Top