C
cinnie
hello gurus
I posted a question 4 or 5 days ago and got two excellent answers from John
Vinson (who used SQL) and Albert Kallal (who combined VBA and SQL). Both
solutions worked far better (faster and easier to implement) than what I had
been doing previously.
My problem is that I don't fully understand why John's SQL code works the
way it does. He suggests replacing the following WHERE clause:
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
with...
WHERE NZ([z], [cboZ]) = cboZ
AND NZ([R], [cboR]) = cboR
AND NZ([D], [cboD]) = cboD
This works perfectly, but as a newcomer to code, I can't see why. What
exactly does 'NZ([z], [cboZ]) = cboZ' mean? If [z] is null, assign
it the value of [cboZ], but how do I interpret the '= cboZ'?
Sorry if this is a dumb question
I posted a question 4 or 5 days ago and got two excellent answers from John
Vinson (who used SQL) and Albert Kallal (who combined VBA and SQL). Both
solutions worked far better (faster and easier to implement) than what I had
been doing previously.
My problem is that I don't fully understand why John's SQL code works the
way it does. He suggests replacing the following WHERE clause:
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
with...
WHERE NZ([z], [cboZ]) = cboZ
AND NZ([R], [cboR]) = cboR
AND NZ([D], [cboD]) = cboD
This works perfectly, but as a newcomer to code, I can't see why. What
exactly does 'NZ([z], [cboZ]) = cboZ' mean? If [z] is null, assign
it the value of [cboZ], but how do I interpret the '= cboZ'?
Sorry if this is a dumb question