- Local time
- Today, 18:51
- Joined
- Feb 19, 2002
- Messages
- 45,438
Rather than ElseIf use a Case statement.
I don't understand your obsession with reusing combos.
You have two options for variable criteria.
1. build a custom WHERE clause that includes only the search fields that contain values.
2. If there are only a few options, you can use static SQL formatted as follows:
WHERE (fld1 = Forms!yourform!fld1 OR Forms!yourform!fld1 Is Null) AND (fld2 = Forms!yourform!fld2 OR Forms!yourform!fld2 Is Null) AND (fld3 = Forms!yourform!fld3 OR Forms!yourform!fld3 Is Null) AND (fld4 = Forms!yourform!fld4 OR Forms!yourform!fld4 Is Null)
Pay attention to the way the parentheses are used to enclose each OR condition.
I don't understand your obsession with reusing combos.
You have two options for variable criteria.
1. build a custom WHERE clause that includes only the search fields that contain values.
2. If there are only a few options, you can use static SQL formatted as follows:
WHERE (fld1 = Forms!yourform!fld1 OR Forms!yourform!fld1 Is Null) AND (fld2 = Forms!yourform!fld2 OR Forms!yourform!fld2 Is Null) AND (fld3 = Forms!yourform!fld3 OR Forms!yourform!fld3 Is Null) AND (fld4 = Forms!yourform!fld4 OR Forms!yourform!fld4 Is Null)
Pay attention to the way the parentheses are used to enclose each OR condition.