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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I make user to enter a valid date?

Status
Not open for further replies.

Chavito21

Programmer
Mar 26, 2003
230
US
Hi everyone,

I am having problems with the user entering not valid dates, like years 2099, 2040. So i am trying to validate de date so on the propertied validation rules, Ima trying to at least enter this years date so this is what I have:
>#1/1/#&quot;Year&quot; And <=&quot;TODAY&quot;

But of course is not working, If you can help me out with the right syntax.

Thanks

Chavito

P.S.
Okay I am just looking at the formula so I thought I want to restrict user to enter 01/01/currrent year AND <= Today's date. but I am just realizing that I may have problems in the begining of the year if on 01/05/2004 if they need to enter 12/29/2003.
So If you have any suggestion of how i can do this. Maybe restruict the user to enter any date <=today or 3 months back.

 
Chavito,

Assuming this is in a text box, in the box's AfterUpdate event, put something like:

Code:
If Me.textboxname < (Date - 90) Or Me.textboxname > (Date + 90) then
Me.textboxname = Null
Me.textboxname.SetFocus.
msgbox &quot;Date must be within 90 days of today's date.&quot;)
End If
 
In the ValidationRule field you have to put

Year([x])=Year(Date()) And <=Date()

where x is the name of the table field containing the date value.
 
Try limiting it with &quot;BETWEEN&quot; in the validation property:
=BETWEEN(#1/1/2000# AND Date())

Cannot test it at the moment, so I can only hope it works the way it should... [pc]

Cheers,
MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany
(andreas.galambos@bowneglobal.de)
HP:
 
Thanks you guys, I just find out that when they get the information the have only one or two dates to entered the information so the date should be only two days from today. I may give them 5 dates.
Again thanks for the help I really appreciated.

 
I suggest in the Data properties for your control:

Validation Rule.......Between Date() - 5 and Date()

Validate Text.........Date must be between 5 days ago and today



HTH,
Bob
Your mileage may vary, but following the guidelines in faq181-2886 will help you reach your goal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top