Solved

acCmdChangeToTextBox

Posted on 2004-10-13
3
374 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:holgrave
3 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 12306258
Hello holgrave,

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
0
 
LVL 1

Author Comment

by:holgrave
ID: 12333259
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??
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12333531
Question answered by asker or dialog valuable.
Closed, 150 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question