Date/Time

depawl

Registered User.
Local time
Today, 09:11
Joined
May 19, 2007
Messages
144
I have a field in a table set to Date/Time. Is it possible to set the properties so that it always defaults to "PM"? In other words, if I enter "5:30" and then TAB, I always want it to be entered as "5:30 PM". Right now it appears to default to "AM". For this particular application, 90% of the entries are made in the PM.
Thanks.
 
depawl,

Convert the date to a string, replace any AM with PM, then convert
it back to a date.

CDate(Replace(CStr([TheDateField], "AM", "PM")))

hth,
Wayne
 
Wayne,
Sorry if my original post was not clear. I do not want to change any of the existing data. For all future entries, I want the default to be "PM" instead of "AM".
Thanks.
 
Depawl,

I know,

Set your date field's Default Value to:

CDate(Replace(CStr(Now()), "AM", "PM"))

Wayne
 
Wayne:
I tried that in both the table and the form (set default value to what you said) and it gave me an error message in both places. Said the function 'Replace' was invalid.
 
Depawl,

The form is the correct place to put it. The Replace is a standard part of VBA
starting after Access 2000. You don't have '97 do you?

If you have '97, just do a search here for replace, there are substitute routines.

Or use this for the form's Default Value:

Code:
=IIf(Now() > CDate(CStr(Date) & " 11:59:59 AM"), Now(), DateAdd("m", 720, Now()))

hth,
Wayne
 
Wayne:
I tried both of your suggestions in the default value of the text box on the form, and when I enter a time it still defaults to AM. Obviously I'm doing something wrong.
Thanks.
 

Users who are viewing this thread

Back
Top Bottom