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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top