I am building a From that has two listboxes. The first listbox (List3) displays all the queries in my database by name. Once you select a query, I want it to display all the properties for that query in the second listbox (List4). The problem I am having is when I select a query it will display a table's properties instead. The table it chooses to display is chosen alphabetically decending, so the top query listed would show the first table, then second to second, etc. I currently was only testing to display the field names in the Query, not all of the properties yet.
My code looks like the following:
Option Compare Database
------------------------------
Sub Form_Load()
Set MyDb = OpenDatabase("DATA.MDB")
Set AllQueryDefs = MyDb.QueryDefs
For i = 0 To AllQueryDefs.Count - 1
List3.AddItem AllQueryDefs(i).Name
Next
End Sub
------------------------------
Private Sub List3_Click()
Do While List4.ListCount > 0
List4.RemoveItem 0
Loop
Set SingleQueryDef = MyDb(List3.ListIndex)
For id = 0 To SingleQueryDef.Fields.Count - 1
List4.AddItem SingleQueryDef.Fields(i).Name
List4.AddItem " "
Next
End Sub
I have a Module Created that defines:
Option Compare Database
------------------------------
Global MyDb As Database
Global SingleQueryDef As QueryDef
Global AllQueryDefs As QueryDefs
Any help would be greatly appreciated. Thanks!