Ok, I know I am gonna make no sense when I say this but here it goes.

First of all I am new to VB (Obviously) and I didn't know that you could build a query on the fly(oopss)! That seems a better way to do it. Either way here is my delima.

I have a combo box, and two list boxes.
I can get the values from my database to populate the combo box by just doing a loop by index as well as the first list box. Now for the second list box things get a little tricky.

First problem: I am going to have to run a query based on the string value in the first list box (That's the value that I have to pass the query) How can I store that vaule in a variable?

Second problem: Preeti, I tried your code and ran into a problem with the rs!field, rs!field2 line of code what does that do and why would I have a problem there? Here is what I have so far, can you tell me what I am doing wrong?


Private Sub List1_Click()
List2.Clear
Dim db As Database
Dim rs As Recordset
Dim sSQL As String
Dim currentindex As String

Set db = Workspaces(0).OpenDatabase(App.Path & "/myprojects/test/inventory2.mdb")

currentindex = "Pine" ' But I need it to be something like this currentindex = list1.text or list1.list something that will grab the string that is currently highlighted in list1 listbox.
sSQL = "SELECT Items.Item FROM " _
& "(Categories INNER JOIN " _
& "[Sub Categories] ON Categories.CatID = " _
& "[Sub Categories].CatID) INNER JOIN " _
& "Items ON [Sub Categories].SubID = " _
& "Items.SubID WHERE ((([Sub Categories]. " _
& "[Sub Category])=['" & currentindex & "']));"
'Note if Sub Category is a string you pass it surrounded by quotes:

Set rs = db.OpenRecordset(sSQL, dbOpenDynaset)

Do Until rs.EOF
List2.AddItem rs!Field1 ' Don't understand this line of code? Especially the rs!...
'vbtab is for spacing
rs.MoveNext
Loop

rs.Close
db.Close


End Sub

Sorry to be such a dummy

[This message has been edited by GiD (edited 07-30-1999).]

[This message has been edited by GiD (edited 07-30-1999).]