D
Doug Wilson
I am trying to build a query to use in creating a report. The records in my
table (tblLiftStation) contain daily entries in two fields ([Meter1] and
[Meter2]) of hour meters connected to electric motors along with an
inspection date ([InspDate]) field. A report would be printed each month
based on the daily records entered during the previous month. I can query
for the daily entries for the previous month using the criteria
Month([Inspdate])=Month(Now())-1 And Year([Inspdate])=Year(Now())
for all months except for December. In that case, the statement
Month([Inspdate])=12 And Year([Inspdate])=Year(Now())-1
filters for the records I need.
I was attempting to build an IIF statement that would combine the two,
basing it on an expression of
Month(Now())=1
then using the
Month([Inspdate])=12 And Year([Inspdate])=Year(Now())-1
as the <truepart> to return the monthly entries for the month of December of
the previous year, and using the
Month([Inspdate])=Month(Now())-1 And Year([Inspdate])=Year(Now())
as the <falsepart> to return the monthly entries for all other months.
The combined statement always returns no records.
table (tblLiftStation) contain daily entries in two fields ([Meter1] and
[Meter2]) of hour meters connected to electric motors along with an
inspection date ([InspDate]) field. A report would be printed each month
based on the daily records entered during the previous month. I can query
for the daily entries for the previous month using the criteria
Month([Inspdate])=Month(Now())-1 And Year([Inspdate])=Year(Now())
for all months except for December. In that case, the statement
Month([Inspdate])=12 And Year([Inspdate])=Year(Now())-1
filters for the records I need.
I was attempting to build an IIF statement that would combine the two,
basing it on an expression of
Month(Now())=1
then using the
Month([Inspdate])=12 And Year([Inspdate])=Year(Now())-1
as the <truepart> to return the monthly entries for the month of December of
the previous year, and using the
Month([Inspdate])=Month(Now())-1 And Year([Inspdate])=Year(Now())
as the <falsepart> to return the monthly entries for all other months.
The combined statement always returns no records.