PDA

View Full Version : change textbox to combo box in VBA



ironj32
05-31-2007, 09:42 AM
I am using this code to change a text box into a combo box with VBA Code.

txtBox.ControlType = acComboBox

when I run it it says "to set this property, open the form in design view" ...which defeats the purpose of doing it in VBA.

any thoughts???

mattj
05-31-2007, 11:20 AM
Perhaps you could open the form in design view and keep it hidden, make the change, and perform the save...

DoCmd.OpenForm "frmYourForm",acDesign,,,,acHidden
txtBox.ControlType = acComboBox

geekgirlau
05-31-2007, 08:15 PM
The other option would be to have 2 controls - a text box, and a combo box placed one on top of the other, and hide whichever is not required.