query conditional show all

A

anna_717717

Hi all, hope someone can help me

I need to filter a query depending on the values on a form.
If a check box is ticked I want to return all the records. If not I want to
filter it by several selection choices. I've tried the code below but this
returns an error 'The expression is typed incorrectly, or it is too complex
to be evaluated'

IIf([Forms]![SelectionForm]![checkAll]=-1,"*",([Task].[TaskID])=[Forms]![SelectionForm]![Selection1]
Or ([Task].[TaskID])=[Forms]![SelectionForm]![Selection2] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection3] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection4] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection5] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection6] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection7] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection8] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection9])

Any help much appreciated
 
M

Marshall Barton

anna_717717 said:
I need to filter a query depending on the values on a form.
If a check box is ticked I want to return all the records. If not I want to
filter it by several selection choices. I've tried the code below but this
returns an error 'The expression is typed incorrectly, or it is too complex
to be evaluated'

IIf([Forms]![SelectionForm]![checkAll]=-1,"*",([Task].[TaskID])=[Forms]![SelectionForm]![Selection1]
Or ([Task].[TaskID])=[Forms]![SelectionForm]![Selection2] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection3] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection4] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection5] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection6] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection7] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection8] Or
([Task].[TaskID])=[Forms]![SelectionForm]![Selection9])


Create a calculated field with a variation of you
expression:

Expr: Forms!SelectionForm!checkAll OR
[Task].[TaskID])=[Forms]![SelectionForm]![Selection1] Or
[Task].[TaskID])=[Forms]![SelectionForm]![Selection2] Or
[Task].[TaskID])=[Forms]![SelectionForm]![Selection3] Or
[Task].[TaskID])=[Forms]![SelectionForm]![Selection4] Or
[Task].[TaskID])=[Forms]![SelectionForm]![Selection5] Or
[Task].[TaskID])=[Forms]![SelectionForm]![Selection6] Or
[Task].[TaskID])=[Forms]![SelectionForm]![Selection7] Or
[Task].[TaskID])=[Forms]![SelectionForm]![Selection8] Or
[Task].[TaskID])=[Forms]![SelectionForm]![Selection9]

The set this field's criteria to:

True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top