View Full Version : Query on Date field


tonyflath
11-15-2001, 02:16 PM
I am trying to use an IIf statement to insert a date entry into fields on a query that are null. Included is the statement I am trying to use.

IIf([Date1] Is Null,[Date1]=#2222/02/02#,[Date1])

What happens when I run the query is that fields with null values result in the entire record being dropped. Any help is appreciated.

Thanks,
Tony

araskas
11-15-2001, 02:41 PM
If [Date1] is a field in the table you need to use UPDATE query not INSERT. Then no need to use IIF.
UPDATE myTable SET myTable.Date1 = #mm/dd/yy#
WHERE (((myTable.Date1) Is Null));

Example :
UPDATE myTable SET myTable.Date1 = #2/2/01#
WHERE (((myTable.Date1) Is Null));

If you are using a form to enter the records into teh tabel then you need to use before insert event proc.



[This message has been edited by araskas (edited 11-15-2001).]

Pat Hartman
11-15-2001, 06:06 PM
You have placed the IIf() in the criteria line. It does not go in the where clause since it is not selection criteria. It goes in the Select clause.

Select IIf(IsNull([Date1]),[Date1]=#2222/02/02#,[Date1]) As YourDate, fld2, fld3, etc.
From YourTable
Where whatever;