Time field continues to show date

  • Thread starter Thread starter Penstar
  • Start date Start date
P

Penstar

I have a time field which I have formatted to medium time eg 07:00 AM. This
is OK until you click on it to edit the time, when the date continues to
popup.

In the time control's "on enter", "on click" and "before update" events I
have set Me.time = Format(Me.time, "hh:nn"). This prevents the time from
showing the date/time.

However, the date/time continues to flick up every time you click on the
field to change the time. It is driving me mad!

Is there any way to fix this?
 
Penstar said:
I have a time field which I have formatted to medium time eg 07:00
AM. This is OK until you click on it to edit the time, when the date
continues to popup.

In the time control's "on enter", "on click" and "before update"
events I have set Me.time = Format(Me.time, "hh:nn"). This
prevents the time from showing the date/time.

However, the date/time continues to flick up every time you click on
the field to change the time. It is driving me mad!

Is there any way to fix this?

DateTime fields in Access always have a date. If you don't see it then it
is 12/30/1899. It is only formatting that hides this from you and that is
disabled when the control has focus. Access has no "Time" field although
some other database engines do. I believe an InputMask would solve that
issue.

Otherwise you could hide your bound control and provide an unbound TextBox
for editing that would just accept the time which you would then copy to the
hidden control in the BeforeUpdate event.
 
Setting the Format property affects only what is *displayed*, i.e. it masks
(but does not change) what the field really contains.

If you want to strip the date from the field, you could use an Update query
to do that.

1. In query design view, choose Update on the query menu.
Access adds an Update row to the design grid.

2. In the Update row under your time field, enter:
TimeValue([Time])

3. Run the query.

That solves the existing records. You will want to figure out how the date
part got into the field so the problem does not keep recurring.

BTW, TIME is a reserved word in JET SQL, and also in VBA where Access may
understand it for the current time. If that really is your field name, you
may want to change it. Here's a reference list of the field names that can
cause you grief:
http://allenbrowne.com/AppIssueBadWord.html
 
Back
Top