Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

acCmdChangeToTextBox

Posted on 2004-10-13
3
Medium Priority
?
399 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

722 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