Solved

acCmdChangeToTextBox

Posted on 2004-10-13
3
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

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…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

738 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