Date syntax problems

  • Thread starter Thread starter Raymond & Lisa Yucha
  • Start date Start date
R

Raymond & Lisa Yucha

I am trying to pass a date back to a query and am having some problems
getting the syntax straight in the iif statement in the query. Essentially
I want to retrieve all records that are >= to the date selected OR return
all records if no date is selected. So far this is what I have and I think
it is close.

Like iif(isnull([forms]![formname]![date]),"*",>=[forms]![formname]![date])

I have tried a bunch of things in the false part of the statement with no
luck (single quotes, double quotes, # signs....you name it) Any help would
be appreciated. Thanks in advance.

Ray
 
Raymond said:
I am trying to pass a date back to a query and am having some problems
getting the syntax straight in the iif statement in the query. Essentially
I want to retrieve all records that are >= to the date selected OR return
all records if no date is selected. So far this is what I have and I think
it is close.

Like iif(isnull([forms]![formname]![date]),"*",>=[forms]![formname]![date])

I have tried a bunch of things in the false part of the statement with no
luck (single quotes, double quotes, # signs....you name it) Any help would
be appreciated. Thanks in advance.

Ray
Ray,
Here is the SQL Where clause.

WHERE YourTable.[ADate] Like IIf(IsNull([forms]![formname]![date]),"*")
OR YourTable.[ADate] >=[Enterforms]![formname]![date]

Note: It's not a good idea to have a field or a control named [Date].
Date is an Access reserved word. At some point your Database is going to
get confused as to whether you are referring to the field/control Date
or the Date function. Change to something else, perhaps dteDate.
 
Back
Top