Results 1 to 4 of 4
  1. #1
    ice051505 is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Feb 2013
    Posts
    76

    Question how to display the data from a query into separate list boxes

    I have one query and 4 list boxes, and I need to put the 4 different fields in this query into these 4 list boxes. I have the code below, somehow, my list boxes give me nothing.

    Below is my code of the optional group which pops up the list box
    Private Sub ArLevl_Click()

    Select Case Me!ArLevl
    Dim sSQL1 As String
    Dim sSQL2 As String
    Dim sSQL3 As String
    Dim sSQL4 As String

    Case 1
    sSQL1 = ("SELECT [AreaQuery_Step1].[TotalArea] FROM [AreaQuery_Step1] ORDER BY [TotalArea];)")
    Me.Slc_MED.RowSource = sSQL1
    Me.Slc_MED.Visible = True
    Me.Slc_SMA.Visible = False


    Me.Slc_SMR.Visible = False
    Me.Slc_SMT.Visible = False
    Case 2
    sSQL2 = ("SELECT [AreaQuery_Step1].[SmallArea] FROM [AreaQuery_Step1] ORDER BY [SmallArea];)")
    Me.Slc_SMA.RowSource = sSQL2
    Me.Slc_MED.Visible = False
    Me.Slc_SMA.Visible = True
    Me.Slc_SMR.Visible = False
    Me.Slc_SMT.Visible = False
    Case 3
    sSQL3 = ("SELECT [AreaQuery_Step1].[SmallerArea] FROM [AreaQuery_Step1] ORDER BY [SmallerArea];)")
    Me.Slc_SMR.RowSource = sSQL3
    Me.Slc_MED.Visible = False
    Me.Slc_SMA.Visible = False
    Me.Slc_SMR.Visible = True
    Me.Slc_SMT.Visible = False
    Case 4
    sSQL4 = ("SELECT [AreaQuery_Step1].[SmallestArea] FROM [AreaQuery_Step1] ORDER BY [SmallestArea];)")
    Me.Slc_SMT.RowSource = sSQL4
    Me.Slc_MED.Visible = False
    Me.Slc_SMA.Visible = False
    Me.Slc_SMR.Visible = False
    Me.Slc_SMT.Visible = True

    End Select
    End Sub

    Please help me to make it work!
    Thanks!

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You have extraneous parentheses in your query text (all four) that may be causing an issue. The query text should just be simply bounded by the double quotes


    sSQL1 = ("SELECT [AreaQuery_Step1].[TotalArea] FROM [AreaQuery_Step1] ORDER BY [TotalArea];)")

  3. #3
    ice051505 is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Feb 2013
    Posts
    76
    Tkz, jzwp11, It worked! Finally.....I got it


    Quote Originally Posted by jzwp11 View Post
    You have extraneous parentheses in your query text (all four) that may be causing an issue. The query text should just be simply bounded by the double quotes


    sSQL1 = ("SELECT [AreaQuery_Step1].[TotalArea] FROM [AreaQuery_Step1] ORDER BY [TotalArea];)")

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Glad you got it sorted out.

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

Similar Threads

  1. Combining separate excel report data
    By mikebravo in forum Import/Export Data
    Replies: 7
    Last Post: 04-16-2012, 01:16 PM
  2. Replies: 5
    Last Post: 03-29-2012, 09:21 PM
  3. Replies: 1
    Last Post: 11-29-2011, 11:17 AM
  4. Replies: 3
    Last Post: 11-26-2010, 12:38 PM
  5. List box to populate other list boxes
    By Nathan in forum Forms
    Replies: 0
    Last Post: 03-03-2009, 07:22 PM

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