holgrave
asked on
acCmdChangeToTextBox
I am trying to change a combobox to a textbox in VBA on form in design mode.
I have a number of controls on the form
cntrl1
cntrl2
cntrl3
My question is how do I select the control before applying the change.
Private Sub MyChangeControlType()
'What goes here before calling the following??
RunCommand acCmdChangeToTextBox
End Sub
I have a number of controls on the form
cntrl1
cntrl2
cntrl3
My question is how do I select the control before applying the change.
Private Sub MyChangeControlType()
'What goes here before calling the following??
RunCommand acCmdChangeToTextBox
End Sub
ASKER
Thanks for the feedback Peter57r.
However the form the controls is on will be shown in Datasheet view only...so having two controls would present the problem of 'moving the columns' around in code....which I REALLY don't have a clue how to do.
I decided to stick with my own solution of changing a combobox to a textbox in VBA in design mode. Here's how:
If ctrl.ControlType = acTextBox Then
ctrl.ControlType = acComboBox
Else
ctrl.ControlType = acTextBox
End If
Please note, if you want to change the name of the control as well (as I did) you have to make the calls in the following order otherwise Access throws a 2467 application errors.
ctrl.Name = "New Name"
ctrl.ControlType = acTextBox
As I have answered my own question I think I will ask for a refund of my points....unless you object Pete??
However the form the controls is on will be shown in Datasheet view only...so having two controls would present the problem of 'moving the columns' around in code....which I REALLY don't have a clue how to do.
I decided to stick with my own solution of changing a combobox to a textbox in VBA in design mode. Here's how:
If ctrl.ControlType = acTextBox Then
ctrl.ControlType = acComboBox
Else
ctrl.ControlType = acTextBox
End If
Please note, if you want to change the name of the control as well (as I did) you have to make the calls in the following order otherwise Access throws a 2467 application errors.
ctrl.Name = "New Name"
ctrl.ControlType = acTextBox
As I have answered my own question I think I will ask for a refund of my points....unless you object Pete??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is a messy operation.
Why not put a textbox and a combo on the form in the same location and make one or other of them visible as required.
This can be done while the form is being used and does not require the form to be opened in design view.
Pete