Home > Archive > MS Access data conversion > August 2005 > Format function in Ms Access 97









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Format function in Ms Access 97
chetna k via AccessMonster.com

2005-08-18, 9:42 am

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.


--
Message posted via http://www.webservertalk.com
Allen Browne

2005-08-18, 9:42 am

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.

--
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.

"chetna k via webservertalk.com" <forum@webservertalk.com> wrote in message
news:530529635555A@w
ebservertalk.com...
>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.



chetna k via AccessMonster.com

2005-08-31, 11:25 am

Thanks for your help.

I used now CDATE function to compare dates and it is working fine.

Thanks
Chetna

chetna k wrote:
>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.



--
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Fo...ersion/200508/1
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com