Form with Multiple Check boxes

P

Paul Washburn

I am trying to write a form with multiple check boxes that will apply filters
to a query result. When none of the boxes are checked all records with be
displayed. If two boxes are checked only records that contain both boxes
would be displayed.

Could someone tell me what the easiest way to do this would be? I was
thinking a switch statement in the where of the sql select.

Thank you for any help.
 
S

S.Clark

Use VBA code to create a dynamic where clause.

If chkA then strW = "{ConditionA}"
If chkB then
if len(strW) > 0 then strW & " AND "
strW = strW & "{ConditionB}"
End If
If chkC then
if len(strW) > 0 then strW & " AND "
strW = strW & "{ConditionC}"
End If

Replace the conditions with some viable criteria.
 
P

Paul Washburn

Thanks,

where would i put that? Ive tried:

SELECT bncforms_table.formnumber, bncforms_table.form_name,
bncforms_table.edi, bncforms_table.events, bncforms_table.notes,
bncforms_table.[Weather Ntc], bncforms_table.Recipients,
bncforms_table.Chapter, bncforms_table.[No Enter],
bncforms_table.Last_Modified
FROM bncforms_table
WHERE If (Forms![FormRpt]![chkEdi] = True) then ([bncforms_table]![edi] =
true)

But its giving me a syntax error.

Is there a way to declare: Where {variable}

And then build the string on the form and pass it through on the button click?
 

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