I am in trouble in comparing two dates:
as I wrote code as
If (Format(Me![Delivery Timescales], "short date") < Format(Now(), "short
date")) Then
MsgBox "Please enter Requested Start date as current date
or any future date", vbCritical
End If
where [Delivery Timescales] is a Text Box and the whole code has been written
on the click of a button.
The Error I am getting is the If condition is coming false as I entered
31/12/2004 in [Delivery Timescales] text box.
Can anybody help?
Thanks in advance.
Allen Browne - 18 Aug 2005 11:50 GMT
Drop the Format() part. Access knows how to compare two dates. You are
forcing it to perform a *string* comparision rather than a date comparison
when you use the Format() function.
Since your dates as d/m/y, take a look at this article:
International Date Formats in Access
at:
http://allenbrowne.com/ser-36.html
It explains how to ensure Access always understands your dates correctly.

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>I am in trouble in comparing two dates:
>
[quoted text clipped - 13 lines]
> The Error I am getting is the If condition is coming false as I entered
> 31/12/2004 in [Delivery Timescales] text box.
chetna k - 31 Aug 2005 15:38 GMT
Thanks for your help.
I used now CDATE function to compare dates and it is working fine.
Thanks
Chetna
>I am in trouble in comparing two dates:
>
[quoted text clipped - 15 lines]
>
>Thanks in advance.