Date() syntax

alexlds

Registered User.
Local time
Today, 00:00
Joined
May 28, 2012
Messages
71
Ive previously got into all sorts of grief trying to compare dates in expressions enclosing them in "" instead of enclosing them in ##

if I do If Date >= [Text17] Then DoCmd.Quit and text17 is returning an expiry date in short date format, will that work without somehow enclosing text17 in ## ?? I presume it will but . . . . .??
 
In Access you would never use quotes for a date/time value. You would use # around a hard-coded date, nothing around a form/field reference as in your example. what you have should work fine.
 
In Access you would never use quotes for a date/time value. You would use # around a hard-coded date, nothing around a form/field reference as in your example. what you have should work fine.

The octothorpes (#) are required in VBA with form references but not in queries.
 
Last edited:
The octothorpes (#) are required in VBA with form references but not in queries.

Say what?!? They are required around a hard-coded date in either place, and they are never required around a form reference. This works fine:

If Me.txtReqDate < Date Then

You may mean when concatenating a form reference into an SQL string in VBA (which is creating a hard-coded date) but that is not what the OP asked about.
 
Say what?!? They are required around a hard-coded date in either place, and they are never required around a form reference. This works fine:

If Me.txtReqDate < Date Then

You may mean when concatenating a form reference into an SQL string in VBA (which is creating a hard-coded date) but that is not what the OP asked about.

Unless the text box has a date format applied in its properties, you are at risk of it failing if you don't use the octothorpes.
 
Unless the text box has a date format applied in its properties, you are at risk of it failing if you don't use the octothorpes.

Perhaps you should have said that instead of "The octothorpes (#) are required in VBA with form references" which isn't accurate.
 
Unless the text box has a date format applied in its properties, you are at risk of it failing if you don't use the octothorpes.

It is better to tell the op that he should format the text boxes for date, especially as he is from the UK and doing so will avoid the US date problems.

Brian
 

Users who are viewing this thread

Back
Top Bottom