Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2008
    Posts
    2

    Displaying Query Properties in a Form


    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!

  2. #2
    Join Date
    Jul 2008
    Posts
    2
    Nevermind, I figured it out. Was a simple mistake that slipped past me.

    ...
    Set SingleQueryDef = MyDb(List3.ListIndex)
    ...

    Needed to be changed to:

    Set SingleQueryDef=AllQueryDefs(List3.ListIndex)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Displaying a picture on a form
    By kydbmaster in forum Forms
    Replies: 4
    Last Post: 04-04-2009, 07:54 PM
  2. form not displaying fields
    By ashiers in forum Forms
    Replies: 0
    Last Post: 09-19-2008, 07:02 AM
  3. Displaying a PDF in a Form
    By Chaz in forum Forms
    Replies: 0
    Last Post: 08-07-2006, 03:26 PM
  4. Form field not displaying in query
    By Valeda in forum Queries
    Replies: 2
    Last Post: 05-05-2006, 10:08 AM
  5. Setting combo box properties
    By rathfam4 in forum Programming
    Replies: 1
    Last Post: 12-28-2005, 02:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums