I have a form with 5 text boxes called: name1, name2, name3, name4, name5.
I have a table containing a field called: name
I want to set up a query so that:
- if the text box name1 is blank, returns all records.
- if one more text boxes are filled in, returns only the specified names.
This is what I have in the query criteria for the name field:
IIF(IsNull([Forms]![formname]![name1]), [tablename]![name], [Forms]![formname]![name1] Or [Forms]![formname]![name2] Or [Forms]![formname]![name3]) Or [Forms]![formname]![name4] Or [Forms]![formname]![name5])
The query works if name1 is null, thereby returning all records. But if name1 contains text (and any of the other text boxes contain text), then it doesn't return anything.
So I don't think it is evaluating the 2nd half of the iif statement correctly. Can someone please help?
I have a table containing a field called: name
I want to set up a query so that:
- if the text box name1 is blank, returns all records.
- if one more text boxes are filled in, returns only the specified names.
This is what I have in the query criteria for the name field:
IIF(IsNull([Forms]![formname]![name1]), [tablename]![name], [Forms]![formname]![name1] Or [Forms]![formname]![name2] Or [Forms]![formname]![name3]) Or [Forms]![formname]![name4] Or [Forms]![formname]![name5])
The query works if name1 is null, thereby returning all records. But if name1 contains text (and any of the other text boxes contain text), then it doesn't return anything.
So I don't think it is evaluating the 2nd half of the iif statement correctly. Can someone please help?