date in SQL statement

  • Thread starter Thread starter Jean-Paul De Winter
  • Start date Start date
J

Jean-Paul De Winter

There is something wrong with following line in my SQL statement:

& " AND DATA.DATUM>=DateAdd('yyyy',-1,#" & [Forms]![weergave
patiënt]![erkdat] & "#) " _

[Forms]![weergave patiënt]![erkdat] is a date field

Can somebody help please
Thanks
 
Try concatenating the formatted date result into the SQL string:
& " AND DATA.DATUM >= " & Format(DateAdd("yyyy", -1, [Forms]![weergave
patiënt]![erkdat]), "\#mm\/dd\/yyyy\#")

That should work, unless the field is null.
 
Trying this in the Immediate Window, I show that DateAdd doesn't like the
single quotes. If that's the case in the query parser as well, try this
instead:

& " AND DATA.DATUM>=DateAdd(""yyyy"",-1,#" & [Forms]![weergave
patiënt]![erkdat] & "#) " _

That's replacing each single quote with 2 double quotes. This will cause the
double quotes to become part of the string instead of them being delimiters
in the current string.
 
Back
Top