Combobox controled by checkbox

  • Thread starter Stephen sjw_ost
  • Start date
S

Stephen sjw_ost

Hello again,

I have been trying to figure this out for hours and need some help please.
My DB has a table which contains 2 columns. Manager and Location.
Manager has multiple manger names and location describes where they are. so;
Manager Jackie is in Location FLO
Manager Deb is in Location FLO
Manager Rich is in Location JAX
Manager Sam is in Location JAX

I have a form with a combobox that has the rowsource set to pull from the
table. The SQL looks like this;

SELECT t_Manager.Manager, * FROM t_Manager;

This pulls all of the managers and works fine.

The form has 2 checkboxes. 1 for JAX and 1 for FLO.

What I am trying to do is, when either or both checkbox(s) is checked, I
want the managers for that location to show in the combobox. When the
checkbox(s) is unchecked, I do not want anything to show in the combobox. If
both checkboxes are checked, I want all of the managers to show in the
combobox.
I have tried adding the location to the SQL statement but the results will
not reflect how I want in the combobox. Here is the SQL statement I've used
to try and pull one or the other or both locations depending on which
checkbox is checked;

SELECT t_Manager.Manager, t_Manager.Location, * FROM t_Manager WHERE
(((t_Manager.Location)=IIf([Forms]![f_Manager]![CB_JAX]=True,"JAX",Null))) OR
(((t_Manager.Location)=IIf([Forms]![f_Manager]![CB_FLO]=True,"FLO",Null)));

The SQL will pull the data like it should, but the combobox will not reflect
it.

Please help. Hope this makes sense.
Thank you in advance.
 
D

Danny J. Lesandrini

You need to requery the combo box. In the After Update event for each
checkbox, put something like this ...

Me!cboMgrList.Requery


Also, this should go in the form Current event, so that as you scroll through
records and the checkbox values change, the combo box reflects that.
 
S

Stephen sjw_ost

Danny,

Thank you for your reply.
I had to tweak a couple of things but your advice worked perfectly.
--
Stephen


Danny J. Lesandrini said:
You need to requery the combo box. In the After Update event for each
checkbox, put something like this ...

Me!cboMgrList.Requery


Also, this should go in the form Current event, so that as you scroll through
records and the checkbox values change, the combo box reflects that.

--
Danny J. Lesandrini
(e-mail address removed)
www.amazecreations.com


Stephen sjw_ost said:
Hello again,

I have been trying to figure this out for hours and need some help please.
My DB has a table which contains 2 columns. Manager and Location.
Manager has multiple manger names and location describes where they are. so;
Manager Jackie is in Location FLO
Manager Deb is in Location FLO
Manager Rich is in Location JAX
Manager Sam is in Location JAX

I have a form with a combobox that has the rowsource set to pull from the
table. The SQL looks like this;

SELECT t_Manager.Manager, * FROM t_Manager;

This pulls all of the managers and works fine.

The form has 2 checkboxes. 1 for JAX and 1 for FLO.

What I am trying to do is, when either or both checkbox(s) is checked, I
want the managers for that location to show in the combobox. When the
checkbox(s) is unchecked, I do not want anything to show in the combobox. If
both checkboxes are checked, I want all of the managers to show in the
combobox.
I have tried adding the location to the SQL statement but the results will
not reflect how I want in the combobox. Here is the SQL statement I've used
to try and pull one or the other or both locations depending on which
checkbox is checked;

SELECT t_Manager.Manager, t_Manager.Location, * FROM t_Manager WHERE
(((t_Manager.Location)=IIf([Forms]![f_Manager]![CB_JAX]=True,"JAX",Null))) OR
(((t_Manager.Location)=IIf([Forms]![f_Manager]![CB_FLO]=True,"FLO",Null)));

The SQL will pull the data like it should, but the combobox will not reflect
it.

Please help. Hope this makes sense.
Thank you in advance.
 

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