Solved

acCmdChangeToTextBox

Posted on 2004-10-13
3
353 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now