Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box help 1

Status
Not open for further replies.

gmacg

Technical User
May 29, 2002
41
US
I have a form with 10 combo boxes. Each combo box has the same 10 list items, and each combo box has a corresponding text box. Selecting an item from any one of the combo boxes populates the corresponding text box. It seems like there would be a way to use one combo box to populate the ten text boxes by looping through the items selected. If not, There should be a way to loop through all of the combo boxes without having to code each one seperately. Access 2000 doesn't have control arrays so I am lost. Am I making sense? Can anyone help me?
 
are the 10combo boxes pulling info from one table
 
gmacg,
You can loop through the combo boxes by using the controls collection of the form, like so:

Private Sub Command10_Click()
Dim ctrl As Control
For Each ctrl In Me.Controls
Select Case ctrl.ControlType
Case 111 '111=combo, 109=textbox, 104=commandbutton
ctrl.AddItem "AAAA"
ctrl.AddItem "BBBB"
ctrl.AddItem "CCCC"
Debug.Print ctrl.Name
End Select
Next
End Sub

I had a problem like yours recently--needed to use the same list to populate several textboxes that were being used as query criteria (they were long and variable, and I didn't want to type them over and over). What I did was use a single combo (actually I used a listbox), and used the double-click event of the textbox to put the current value of the list into the textbox that was double-clicked.

It worked fine.

Tranman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top