How to switch combo boxes?


L

LAS

I have a control on a form (bound to a field from a table) which in one set
of circumstances should show one set of values in the combo box and in
another set of circumstances a different set. I thought about putting the
field on the form twice, and switching the visible/enabled values, but I
can't change the name. No way to distinguish the two. I looked for the
combo box in intellisense for the control and control.properties, but I
didn't see anything that looked useful. Can I switch the contents of a
combo box programattically?

TIA
LAS
 
Ad

Advertisements

S

Stuart McCall

LAS said:
I have a control on a form (bound to a field from a table) which in one
set of circumstances should show one set of values in the combo box and in
another set of circumstances a different set. I thought about putting the
field on the form twice, and switching the visible/enabled values, but I
can't change the name. No way to distinguish the two. I looked for the
combo box in intellisense for the control and control.properties, but I
didn't see anything that looked useful. Can I switch the contents of a
combo box programattically?

TIA
LAS

Create and save two queries, one to fetch the first set, one for the second
set. Make sure you're getting the correct data in each case. Then simply
swap the combo's rowsource like this

Me.MyCombo.RowSource = "Query1"
or
Me.MyCombo.RowSource = "Query2"

(obviously you should use appropriate control/query names)
 

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