acCmdChangeToTextBox

E

Edward Rothwell

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
 
A

Allen Browne

Just change the ControlType of the contol to acTextBox.

This example converts all labels to text boxes (assuming a form open in
design view):
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acLabel Then
ctl.ControlType = acTextBox
End If
Next

More detailed example:
http://members.iinet.net.au/~allenbrowne/ser-46.html
 
E

Edward Rothwell

Hi Allen,

Thanks for that - it works just great.

One thing I discovered was that for what I want to work I have to make
the calls in the right order, otherwise Access thows a 2467
Application Error.

If I do:

ctrl.ControlType = bytControlType
ctrl.Name = strQualifierName

....I get the error.

If I do:

ctrl.Name = strQualifierName
ctrl.ControlType = bytControlType

....everything works just great :)

Thanks again.

Ed.
 

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