52MikeH
Nov 7 2005, 02:21 AM
I am new to Access so please excuse me if this is a realy simple question.
I have 2 linked list boxes (list0 and list2)which have the following Vb Code
Private Sub Form_Load()
With Me.List0
.RowSource = _
"SELECT DISTINCT SUPPLIER FROM Ranges " & _
"WHERE Supplier IS NOT NULL"
.ColumnCount = 2
.BoundColumn = 1
.ColumnWidths = "0.5 IN;1.2 IN"
End With
End Sub
Private Sub List0_AfterUpdate()
With Me.List2
.RowSource = _
"SELECT RangeName FROM Ranges " & _
"WHERE Supplier = " & Me.List0
.Requery
End With
Me.Label5.Caption = Me.List2.ListCount & " Ranges in " & _
Me.List0
End Sub
When list box loads the list only shows the ID key for the field and not the text!
The second List Box loads okay when a selection is made in the first.
Now if I look at the table where the data is stored the Supplier field(which is a combo box based on another table)shows text for the suppliers name.
Does anyone know how I can get the supplier text into the list box ?
Thanks
Mike
HiTechCoach
Nov 7 2005, 02:30 AM
Welcome to Utter Access!
To get the supplier's name, you will need to add the supplier table to the query's SQL and link on the supplier ID. Then you can add the name field(s) for the supplier to your listbox.
Hope this helps...
52MikeH
Nov 7 2005, 04:25 PM
Thanks For welcome HiTechCoach,
I have tried this but I either get the type mismatch or the list box stops working !
To explain a little further what I am trying to do.
I have a table 'Suppliers' which has the following fields:-Supplier,street,Town,postcode,TelNo
I have a table 'Ranges' which has the following fiels:- RangeName,RollPrice,RetailPrice,Widths,Supplier(which is a combo box sourcing data from the Table Suppliers)
Both tables look okay and all data is fine.
I have created a Form with 3 list boxes,on opening the form it loads the first list box with all the 'Distinct' Supplier names (or it should)!
Then when one of the supplier list are selected the second list box loads with all the RangeName details of that supplier.
Going back to the original posting if in the first part of the code I have "SELECT DISTINCT Supplier FROM Suppliers" then the first list box loads okay and the names are visible,but the second list does not load when one of the Supplier are selected.
Does this make any sense ?
Mike
Edited by: 52MikeH on Mon Nov 7 16:30:16 EST 2005.
annalyst
Nov 12 2005, 11:42 AM
I'm not sure if this is all you need.
I use the same method for States and District.
Put these in your query in the criteria field one for Suppliers and one for Ranges
[Forms]![YourFormNameHere]![YourComboBoxNameforSuppliers]
[Forms]![YourFormNameHere]![YourComboBoxNameforRanges]