Changing Multiple Text Boxes to Combo Boxes

Jenaccess

Registered User.
Local time
Today, 12:08
Joined
Sep 8, 2010
Messages
67
Hi,

I'm just curious whether there is a way to convert multiple text boxes to combo boxes all at once, rather than right clicking on them one at a time, and selecting Change to.

I have a form with about 50 fields and most of them need to be converted to combo boxes. I'd always done it manually one at a time up to this point, but I'm trying to build up my learning and look for smarter ways to do things.

In my research I haven't found anything that even touches on this, let alone how to do it. I'm just wondering if such a thing is even possible.

Thank you for your time!

(Using Access 2010)
 
The info I have found suggests leave the textboxes alone; create the combos you want and just make the combos visible and the text boxes invisible.

I tried this, but it would error saying the
"Application.RunCommand acCmdChangeToComboBox" command was Not available at this time.

Code:
Sub ChangeTextboxestoCombos()

Dim DB As DAO.Database
Dim ctl As Control
DoCmd.OpenForm "frmTextBoxToCombo", acDesign
For Each ctl In Forms.frmTextBoxToCombo.Controls
  If ctl.ControlType = acTextBox Then
    Debug.Print ctl.name
    ctl.SetFocus
    Application.RunCommand acCmdChangeToComboBox
    Debug.Print "changed It"
  Else
  Debug.Print ctl.ControlType; ctl.name
  End If
Next ctl
End Sub
 
Would leaving the texts alone and creating combos just create an extra step to achieve the same goal, or are there additional benefits to doing it that way?

Thank you for taking the time to answer my question. I really appreciate it.
 
I just did some google searching based on the subject. I tried using some vba to convert textboxes to combos. I could not get the vba to do the job --I may be missing something very basic?? I did not find an automated solution, but comments about having both and just making the combo visible.

Some of these links are for textbox to combo, some are combo to textbox -- but the concept is to do a change of control type via vba.

Take a look at these:
http://www.pcreview.co.uk/forums/convert-text-box-combo-box-using-vba-t3680124.html

http://answers.microsoft.com/en-us/...x-in-vba/5ba23c8a-21fc-422f-97f2-7547dc4c60ca

http://bytes.com/topic/access/answers/639468-changing-combo-box-text-box
 
I just wanted to say thank you again for responding and for your help. I looked at the information in the links you sent, and that seems the best way to go. I appreciate you taking the time to help me.
 

Users who are viewing this thread

Back
Top Bottom