Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Field Validation Rule for Date and Time

Status
Not open for further replies.

networkwoes

Technical User
Aug 17, 2001
13
0
0
US
I have a field that I want to contain the Date and 24hr time. But I am having trouble enforcing the format. I am using a text field because I could not modify a date field to look the way I wanted (finished input should look like 12/25/03 2330 CTZ). I have a rule that sort of works but allows a few things through that I cant have such as a time of 0000 and some are putting in mm/dd/yy instead of the actual date. The rule I have now is:

Like "??/??/?? ???? CTZ" Or "00/00/03"

I tried to use:

Like "??/??/?? ???? CTZ" Or "00/00/03" And Not Like "??/??/?? 0000 CTZ " And Not Like "MM/DD/YY ???? CTZ"

To prevent the other invalid entries with no success, can anyone shed some light on this for me?

Thanks for helping a uninformed soul!!!
Lack of Knowledge is very aggravating...
 
nww,

This is from the Help file using FORMAT. It will do what you wish.

Dim MyTime, MyDate, MyStr
MyTime = #17:04:23#
MyDate = #January 27, 1993#

' Returns current system time in the system-defined long time format.
MyStr = Format(Time, "Long Time")

' Returns current system date in the system-defined long date format.
MyStr = Format(Date, "Long Date")

MyStr = Format(MyTime, "h:m:s") ' Returns "17:4:23".
MyStr = Format(MyTime, "hh:mm:ss AMPM") ' Returns "05:04:23 PM".
MyStr = Format(MyDate, "dddd, mmm d yyyy") ' Returns "Wednesday,
' Jan 27 1993".
' If format is not supplied, a string is returned.
MyStr = Format(23) ' Returns "23".

' User-defined formats.
MyStr = Format(5459.4, "##,##0.00") ' Returns "5,459.40".
MyStr = Format(334.9, "###0.00") ' Returns "334.90".
MyStr = Format(5, "0.00%") ' Returns "500.00%".
MyStr = Format(&quot;HELLO&quot;, &quot;<&quot;) ' Returns &quot;hello&quot;.
MyStr = Format(&quot;This is it&quot;, &quot;>&quot;) ' Returns &quot;THIS IS IT&quot;.

Rollie E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top