How to switch combo boxes?

  • Thread starter Thread starter LAS
  • Start date Start date
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
 
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)
 
Back
Top