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

Displaying values in a list box from a value in a combobox 1

Status
Not open for further replies.

Herriot

MIS
Dec 14, 2001
45
GB
Despite an extensive search of the forums I cannot find a solution to my problem so I apologise in advance if this has been asked and answered (if it has can you point the way). I am having great problems displaying values in a ListBox depending on what value the user chooses from a ComboBox. I would be grateful for any help.
I have two tables as follows:
Table 1 = tblStock
Fields: Stock_ID; Stock_Description
Table 2 = tblSizes
Fields: Size_ID; Size; Qty; Stock_ID
(NB The stock is work garments and their sizes and quantities)

I would like to have a ComboBox that displays the stock (Trousers,Shirts etc) and just below that a ListBox that displays the Sizes and Quantities associated with a piece of stock.

Example:
If the user chooses Trousers from the dropdown ComboBox only those sizes (and quantities) associated with the stock item chosen would be displayed in the ListBox below.

Ala...
Trousers
Size - Qty
36 - 3
40 - 10
:
etc
(depending on garment there can be up to 15 different sizes)

I have been trying this for ages and I am obviously making a fundamentally basic error but I can't figure out what that is.

I have managed to get a ComboBox to show only the stock Items so that the user can choose what they want. But, here lies the problem, the list box I placed displays ALL sizes and quantities for ALL stock items.

Regards

Herriot
 
I think this will do the trick,

In the underlying query for the list box, put this in the criteria [screen].[ActiveForm].[ComboBoxName]

To have the list box clear it's entry, in the after update of the Combo box put code to set value to "" and to requery the list box.

Let me know if this works!

Dawn
 
OOps, little error, In the underlying query for the list box you must bring in the table that holds the items for the combo box. Then ad the key field and put the criteria I wrote above in that field. Also uncheck the show box so that field doesn't show up in the list box.

I Hope I haven't confused you more
 
Hi Dawn. Excellent!

After a bit of tweaking (and pulling a bit more of what hair I have left out) I have got it to work. Though I couldn't figure out how to code the "" you said but it doesn't matter as it appears to work okay without that.

Thanks a million.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top