Dealing with empty controls in WHERE clauses

C

cinnie

hi to all
in my SELECT statement, I have a WHERE clause like this...

WHERE Region = Forms!RegionStats.cbxRegion
AND County = Forms!RegionStats.cbxCount
AND Zone = Forms!RegionStats.txtZone

The query works great when all three controls have values, but i would also
like it to work if only one or two controls have values. What is the best
way to 'neglect' empty controls so that any SELECTING is determined only by
the controls that actually have values?
 
D

Damon Heron

This might work. Check out the nz function in Help


WHERE Region = nz(Forms!RegionStats.cbxRegion)
AND County = nz(Forms!RegionStats.cbxCount)
AND Zone = nz(Forms!RegionStats.txtZone)

Damon
 
Top