Open Form based on Check Boxes

S

slack.steve

I have a form with several check boxes. I have created an unbound form
with checkboxes. I want to be able to open the bound form based on the
check boxes selected on the unbound form. As there are several check
boxes, if the user selects a checkbox, the bound form should open based
on these check boxes, but on the checkboxes that aren't checked, I want
all the records that do or don't have that certain checkbox checked. I
tried using a SQL statement saying select records where main.chkbx1
like query_form chkbx1 or main.chkbx2 like query_form chkbx2 ..... etc
but if I select multiple check boxes, it will bring up the records if
any one check box I have selected is in the record. If multiple
checkboxes are selected, I want records that have both of those
selected, not just one or the other - and I don't want other check
boxes to matter if I didn't select them on the query form.
 
P

Powderfinger

How are you opening the bound form now? You say it works but is in the OR
condition. You want to change it to the AND condition. Please post the code
that opens the form (perhaps in the OnClick event of a button)
 
J

jahoobob via AccessMonster.com

You didn't stae where these SQL statement are so I can give you a generic
answer
You need AND instead of OR and a wild card (*) in your LIKE statements
 
S

slack.steve

I just do a simple command:

stDocName = "Results_Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

The Results_Form is based on a query that has that SQL statement I
posted. Changing to an AND condition would bring up the records only
as I have checked - I want it to bring up what I checked, but disregard
what I haven't checked.
 
S

slack.steve

I just do a simple command:

stDocName = "Results_Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

The Results_Form is based on a query that has that SQL statement I
posted. Changing to an AND condition would bring up the records only
as I have checked - I want it to bring up what I checked, but disregard
what I haven't checked.
 
M

metalhead

The SQL statements are in a query. I base the results form on this query.
Wouldn't
changing the ORs to an AND condition bring up the records only
as I have checked - I want it to bring up what I checked, but ignore the
fields I haven't checked.
You didn't stae where these SQL statement are so I can give you a generic
answer
You need AND instead of OR and a wild card (*) in your LIKE statements
I have a form with several check boxes. I have created an unbound form
with checkboxes. I want to be able to open the bound form based on the
[quoted text clipped - 9 lines]
selected, not just one or the other - and I don't want other check
boxes to matter if I didn't select them on the query form.
 
J

jahoobob via AccessMonster.com

You stated "not one OR (my emphasis) the other." I'm taking you at your word.

The wild card takes care of that. If there is nothing in [Forms]![query_form]
![chkbx1] then this statement:
Like [Forms]![query_form]![chkbx1] & "*"
becomes:
Like " *"
and will show everything
Try it.
The SQL statements are in a query. I base the results form on this query.
Wouldn't
changing the ORs to an AND condition bring up the records only
as I have checked - I want it to bring up what I checked, but ignore the
fields I haven't checked.
You didn't stae where these SQL statement are so I can give you a generic
answer
[quoted text clipped - 5 lines]
 
S

slack.steve

Is it possible to put an If statement in to check and see if there is
nothing?
jahoobob said:
You stated "not one OR (my emphasis) the other." I'm taking you at your word.

The wild card takes care of that. If there is nothing in [Forms]![query_form]
![chkbx1] then this statement:
Like [Forms]![query_form]![chkbx1] & "*"
becomes:
Like " *"
and will show everything
Try it.
The SQL statements are in a query. I base the results form on this query.
Wouldn't
changing the ORs to an AND condition bring up the records only
as I have checked - I want it to bring up what I checked, but ignore the
fields I haven't checked.
You didn't stae where these SQL statement are so I can give you a generic
answer
[quoted text clipped - 5 lines]
selected, not just one or the other - and I don't want other check
boxes to matter if I didn't select them on the query form.
 
J

jahoobob via AccessMonster.com

Have you tried my suggestions?

Is it possible to put an If statement in to check and see if there is
nothing?
You stated "not one OR (my emphasis) the other." I'm taking you at your word.
[quoted text clipped - 17 lines]
 
S

slack.steve

Yes - that gets all records. How can I make it get just the records
that have a checkbox if the check box is checked, if the other
checkboxes are not check bring all those records?

Thanks for your help!
jahoobob said:
Have you tried my suggestions?

Is it possible to put an If statement in to check and see if there is
nothing?
You stated "not one OR (my emphasis) the other." I'm taking you at your word.
[quoted text clipped - 17 lines]
selected, not just one or the other - and I don't want other check
boxes to matter if I didn't select them on the query form.
 

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