Date >=startdate <=enddate not functionin

deanvilar

Registered User.
Local time
Today, 03:37
Joined
Mar 27, 2013
Messages
63
what seems to be wrong with my date between syntax ???? =(

Code:
ElseIf CDate(tstEndDate) >= CDate(Forms![ASSET_MOVEMENT_PRINT_MODULE]!txtFromDate) <= CDate(Forms![ASSET_MOVEMENT_PRINT_MODULE]!txtToDate) Then
 
Your provided code is comparing between three total dates. VBA If statements I do not believe are not capable of evaluating three things directly without grouping parenthesis to work within the requirements.
 
can you give me an example of grouping this syntax of mine?
 
you need similar to this

cdate >= startdate and cdate <= enddate

altrernatively

cdate between startdate and enddate

note that if you are in the UK, you may need to disamibguate the dates - as in some cases access/vba will treat ambiguous dates as US, not UK

eg 1/5/2013 (1st May) may get treated as 5/1/2103 (5th Jan)
 
Thanks for ur reply yes i just made something like that and worked thanks thanks
 
gemma-the-husky; said:
note that if you are in the UK, you may need to disamibguate the dates - as in some cases access/vba will treat ambiguous dates as US, not UK

eg 1/5/2013 (1st May) may get treated as 5/1/2103 (5th Jan)

This only applies to date strings ie surrounded by## if the dates are in controls or fields then they will be in double format. The situation that catches people out is in SQL. Strings as the dates are formatted for execution and thus the Format function is required to ensure the correct format is used.

Brian
 

Users who are viewing this thread

Back
Top Bottom