Can I change COMBO to TEXT using code?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Would be cool to change a TEXT BOX to a COMBO BOX using the .gotfocus
property on my forms. Is this possible and ,if so, what would the code
looking like?

Thanks.

Bill
 
You can change the ControlType, but only in *design* view.

Open the form in design view (hidden if desired), and change the
ControlType, e.g.:
Forms!Form1.Text0.ControlType = acComboBox
Then assign the new properties such as ColumnCount, ColumnWidths,
BoundColumn, and RowSource.

If you are interested in an example of changing one type of control into
another, see:
http://members.iinet.net.au/~allenbrowne/ser-46.html
The code in that article converts labels into text boxes, to work around a
bug in Access 2003 where unbound labels flicker if their Parent is anything
other than the form.
 
Bill Mitchell said:
Hi,

Would be cool to change a TEXT BOX to a COMBO BOX using the .gotfocus
property on my forms. Is this possible and ,if so, what would the
code looking like?

Thanks.

Bill

You can't actually change the type of a control at run time. You could,
howver, swap in one control for another, by having two controls bound to
the same field and having only one be visible at a time. From what
little you say about what you have in mind, you may want to try the
trick of having a text box sit on top of a combo box. Then in the
GotFocus event of the text box, set the focus to the combo box. That
automatically brings the combo box to the front, while it has the focus,
but when the combo box loses the focus the text box comes to the front
again.
 
Back
Top