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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make second combo go to match from first combo.

Status
Not open for further replies.

Gofaster

Technical User
Apr 23, 2001
13
GB
Hi
I am sure this has been answered before but I can't find it.

I have two combo boxes call them A & B when the user selects the value in A I want combo B to jump to the nearest match from column 2 in combo A

Thanks

 
What is the recordsource of combo box 2 please? Is it a table, a query, or a value list?
 
Its a querry of a table "by" the combo box. i.e SQL
 
KenReay

I saw that one but i didn't really get it, and I couldn,t see how it looks at column 2 in combo A to set the value for combo B.
 
So, let's say we're talking cars. Combobox_A wants to select the MAKE

Toyota
Nissan
Ford
Chevrolet
Honda

when the user selects Ford in ComboBox_A, you want Ford to also show up in ComboBox_B?



Leslie
 
No
This is what I wanted and seems to work.
Me.ComboB = Me.ComboA.Column(1)

Just found it in a demo database
Thanks for your help chaps.
 
Gofaster

when the user selects the value in A I want combo B to jump to the nearest match from column 2 in
Do you mean you want the second combo box to only include elements restricted by column A?

You do this by controlling the RecordSource property of the second combo box.

An example for the AfterUpdate event procedure for the first combo box...

Assumptions:
- cmbMenuCat1 - menu categories, text string
- cmbMenuItem2 - menu items

After update of Menu Category, limit selection of menu items specific for select menu category - drinks, dessert, entré
Code:
Dim strSQL as String, strQ as String

strQ = Chr(34)

If Len(nz(Me.cmbMenuCat1,"")) > 0 Then
    strSQL = "Select MenuItem From tblMenuItem " _
    & "Where MenuCat = " & strQ & Me.cmbMenuCat1 & strQ
    Me.cmbMenuItem2.RecordSource = strSQL
    Me.cmbMenuItem2.Requery
End if

If there is a valid menu category
- change the record source for the 2nd combo box, MenuItem to only include items specific to the selected category.
- Repopulate the MenuItem combo box using the Requery method.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top