S
Stephen @ ZennHAUS
Hi Guys and Gals,
I have a number of reports each fed by a different query. In each query I
have criteria supplied by a form
(for example, Between [forms]![frmDateRange]![txtDateFrom] And
[forms]![frmDateRange]![txtDateTo])
which works just fine.
However, now I want to add the option to specify additional criteria using
the form such as an equipment
number, operator etc. Naturally, each criteria is not being specified each
time the report is being run and
so I need to include certain criteria only when it is chosen in the form. So
I used an IIf statement to try and
make the criteria only apply when the combo box on the form is filled out
(for example, IIf([forms]![frmDateRange]![cbxEquipment] Not IsNull,
[forms]![frmDateRange]![cbxEquipment]) )
When the query is run from the form, if the combobox has something in it, it
works fine, but if there is nothing in the combobox, the report displays
nothing. If I remove the IIF statement from the criteria, the report
displays all of the records regardless of which equipment it is (as you
would expect).
What am I doing wrong with my IIf statement? Is there a better way to do
this especially considering some reports will have up to 5 criteria
specified or not.
Cheers
Stephen @ ZennHAUS
I have a number of reports each fed by a different query. In each query I
have criteria supplied by a form
(for example, Between [forms]![frmDateRange]![txtDateFrom] And
[forms]![frmDateRange]![txtDateTo])
which works just fine.
However, now I want to add the option to specify additional criteria using
the form such as an equipment
number, operator etc. Naturally, each criteria is not being specified each
time the report is being run and
so I need to include certain criteria only when it is chosen in the form. So
I used an IIf statement to try and
make the criteria only apply when the combo box on the form is filled out
(for example, IIf([forms]![frmDateRange]![cbxEquipment] Not IsNull,
[forms]![frmDateRange]![cbxEquipment]) )
When the query is run from the form, if the combobox has something in it, it
works fine, but if there is nothing in the combobox, the report displays
nothing. If I remove the IIF statement from the criteria, the report
displays all of the records regardless of which equipment it is (as you
would expect).
What am I doing wrong with my IIf statement? Is there a better way to do
this especially considering some reports will have up to 5 criteria
specified or not.
Cheers
Stephen @ ZennHAUS