Unable to display values in 2nd list box from 1st list box selection


Joined
Jan 22, 2017
Messages
1
Reaction score
0
I have two list boxes in a Form:


List box 1 Name: Select Ingredient
List box 1 Row Source: SELECT tblIngredients.IngredientID, tblIngredients.Ingredient
FROM tblIngredients
ORDER BY tblIngredients.Ingredient;
List box 1 Bound Column: 1

List box 2 Name: List Products

Table 1 Name: tblIngredients
Table 1 Field Name: IngredientID (AutoNumber)
Table 1 Field Name: Ingredient (Short Text); Indexed (No Duplicates)
Table 1 Field Name: IngredientDescription (Short Text)


Table 2 Name: tblProducts
Table 2 Field Name: ProductID (AutoNumber)
Table 2 Field Name: Product (Short Text); indexed (No Duplicates)
Table 2 Field Name: Product Description(Short Text)


Table 3 Name: tblProductIngredientJoin
Table 3 Field Name: ProductIngredientID (Autonumber)
Table 3 Field Name: ProductID (Number); Indexed (Duplicates OK)
Table 3 Field Name: IngredientID (Number); Indexed (Duplicates OK)


Relationship:

tblIngredients.IngredientID (1 to many with Enforce Referential Integrity) to tblProductIngredientJoin.IngredientID
tblProducts.Product (1 to many) to tblProductIngredientJoin.ProductID


I don’t know what I need to code in the 2nd unbound list box where I select an item from listbox 1 (Ingredient) and displays all the matching (Product) results in list box 2.
 
Joined
Apr 13, 2017
Messages
3
Reaction score
0
Example

Make One Table And save To 1 Another Save To 2

Table 1 Including One Field : Digit

Digit
1
2
3
4
5
6

Table 2 Including Two Fields: Digit,Subdigit

Digit SubDigit
1 10
1 100
1 1000
2 20
2 200
3 30
3 300
3 3000
3 30000

Use List0 And List2 In Form Or Another Name In Your Option Or Automatically By Access

Write In Event Click Of First List Box ( List0 ) Following Code


Private Sub List0_Click()

h = List0.ItemData(List0.ListIndex)

strSQL = "select subdigit from 2 where digit like '" & h & "'"

List2.RowSource = strSQL
List2.RowSourceType = "table/query"



End Sub

I Hope To Give You Proper Reply
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top