I’m trying to build a query (using query builder) that will change the criteria on a field (Num) depending on the value of text box (TB1) on form (frm1)
So if TB1 is left blank (Null) then I want the criteria field to match everything in Num. If the value is non-Null (ie an actual value entered) then I want to match against just that value.
Simplified Example – I have a Table
ID Num
1 44
2 55
3 66
4 empty - Null
5 empty - Null
6 77
If I create a simple query in query builder to list all the ID’s with the following criteria on Num - ‘Like * ‘
I get back records 1,2,3 and 6 (ie the non Null’s in Num)
If I use the Criteria - ‘ Like * or is Null’
then I get back all the records – which is what I want.
Now if I put this criteria in an IIF statement like this
IIF(TB1 is null, (Like * or is Null), TB1)
Then I get back no records at all - which I can’t explain.
Can you explain – or better still – think of a way to make this work. Even in SQL would be useful
Thanks
So if TB1 is left blank (Null) then I want the criteria field to match everything in Num. If the value is non-Null (ie an actual value entered) then I want to match against just that value.
Simplified Example – I have a Table
ID Num
1 44
2 55
3 66
4 empty - Null
5 empty - Null
6 77
If I create a simple query in query builder to list all the ID’s with the following criteria on Num - ‘Like * ‘
I get back records 1,2,3 and 6 (ie the non Null’s in Num)
If I use the Criteria - ‘ Like * or is Null’
then I get back all the records – which is what I want.
Now if I put this criteria in an IIF statement like this
IIF(TB1 is null, (Like * or is Null), TB1)
Then I get back no records at all - which I can’t explain.
Can you explain – or better still – think of a way to make this work. Even in SQL would be useful
Thanks