Date/Time: Conditional Formatting vs. Format Property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working with a continuous form in Access 2002. The form's recordsource
has date/time fields named StartTime and EndTime, which store complete
date/time information. I would like to format my textboxes to show date only
(m/d/yyyy) if the date is before today and time only (h:nn AM/PM) if the date
is equal to today. StartTime will therefore show:

3/1/2006
3/17/2006
3/17/2006
3/30/2006
9:15 AM

for 4 records prior to today and a fifth from today.

Conditional formatting lets me change the font color, background color,
etc., based on the comparison of the value to Date(), but it doesn't seem to
have a place to enter *number format*.

If I change the number format via the textbox's Format property, the setting
is applied across all records in the continuous form.

Does anyone have tricks for changing *number format* conditionally, short of
a calculated (and therefore uneditable) field?

Thanks.
 
You will have to use the Format() function in a calculated control.

To handle the editing part, keep the real control bound to the date field as
well as the calc control. In the Enter event of the calc control, SetFocus
to the real one, so it can be edited.

If you set the Tab Stop to No for the real control, and the tab order to the
correct place for the calc control, it should all work smoothly.
 
Back
Top