C
cinnie
greetings
I have a form with 3 comboboxes: cboZone, cboRegion and cboDivision. When
the user clicks a button on the form, a query is run. The WHERE clause of
the query starts like this:
WHERE (
(S.Zone = Forms!frmReport.cboZone)
And (S.Region = Forms!frmReport.cboRegion)
And (S.Division = Forms!frmReport.cboDivision))
OR etc...
Using abbreviations for simplicity, the entire WHERE clause is:
WHERE (Z=cboZ AND R=cboR AND D=cboD) '0 nulls
OR (Z=cboZ AND R=cboR AND D is Null) 'exactly 1 null
OR (Z=cboZ AND R is Null AND D=cboD)
OR (Z is Null AND R=cboR AND D=cboD)
OR (Z=cboZ AND R is Null AND D is Null) 'exactly 2 nulls
OR (Z is Null AND R=cboR AND D is Null)
OR (Z is Null AND R is Null AND D=cboD)
OR (Z is Null AND R is Null AND D is Null) '3 nulls
The SQL works fine, but now I need to add another combobox to the form,
cboArea. This means that the WHERE clause will have 16 parts instead of 8.
Here is my question. Is there a simpler or more effecient way to write this
WHERE clause that will produce the same result? I need it to cover the cases
where none, exactly 1, exactly 2, exactly 3, and all 4 of the cbos are null.
much thanks for any clues
Cinnie
I have a form with 3 comboboxes: cboZone, cboRegion and cboDivision. When
the user clicks a button on the form, a query is run. The WHERE clause of
the query starts like this:
WHERE (
(S.Zone = Forms!frmReport.cboZone)
And (S.Region = Forms!frmReport.cboRegion)
And (S.Division = Forms!frmReport.cboDivision))
OR etc...
Using abbreviations for simplicity, the entire WHERE clause is:
WHERE (Z=cboZ AND R=cboR AND D=cboD) '0 nulls
OR (Z=cboZ AND R=cboR AND D is Null) 'exactly 1 null
OR (Z=cboZ AND R is Null AND D=cboD)
OR (Z is Null AND R=cboR AND D=cboD)
OR (Z=cboZ AND R is Null AND D is Null) 'exactly 2 nulls
OR (Z is Null AND R=cboR AND D is Null)
OR (Z is Null AND R is Null AND D=cboD)
OR (Z is Null AND R is Null AND D is Null) '3 nulls
The SQL works fine, but now I need to add another combobox to the form,
cboArea. This means that the WHERE clause will have 16 parts instead of 8.
Here is my question. Is there a simpler or more effecient way to write this
WHERE clause that will produce the same result? I need it to cover the cases
where none, exactly 1, exactly 2, exactly 3, and all 4 of the cbos are null.
much thanks for any clues
Cinnie