Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Location
    British Columbia, Canada
    Posts
    29

    Unanswered: ListBox RowSource issues...

    Hi guys,

    In Access 2007, I've got a ListBox control which I would like to have dynamically change depending on a group of toggle buttons. I have one toggle button working, which is based on a value list that I've defined, but I can't seem to get it to switch to a Table/Query source for the next toggle button option. I've fought with the issue for a while now, and would love some input on your guys' behalf. The query in question was pasted into the Access Query builder and the correct values were produced, so I don't think it's an error in the SQL.

    Here's my code. The QUERY_BY_SALES_REP branch is the branch in question.

    Code:
    Private Sub QueryTypeFrame_Click()
    
        'Enable the ParameterList (ListBox); it's used for each option
        If ParameterList.Enabled = False Then
            ParameterList.Enabled = True
        End If
        
        Select Case QueryTypeFrame
        
            Case QUERY_BY_MONTH
                'This option doesn't use the search term text box, so gray it out.
                If SearchTermTextBox.Enabled = True Then
                    SearchTermTextBox.SetFocus
                    SearchTermTextBox.Text = ""
                    QueryTypeFrame.SetFocus
                    SearchTermTextBox.Enabled = False
                End If
                
                'Set the ListBox up
                ParameterList.ColumnCount = 2
                ParameterList.RowSourceType = "Value List"
                ParameterList.RowSource = "1;""January"";2;""February"";3;""March"";4;""April"";5;""May"";6;""June"";7;""July"";8;""August"";9;""September"";" & _
                                  "10;""October"";11;""November"";12;""December"""
                
            Case QUERY_BY_DATE_RANGE
                'TODO: Complete this option
                
            Case QUERY_BY_SALES_REP
                'This option doesn't use the search term text box, so gray it out.
                If SearchTermTextBox.Enabled = True Then
                    SearchTermTextBox.SetFocus
                    SearchTermTextBox.Text = ""
                    QueryTypeFrame.SetFocus
                    SearchTermTextBox.Enabled = False
                End If
                
                'Set the ListBox up. This is where my issue is. My ListBox
                'appears blank even after running this block of code.
                'It does go blank after showing all the months from the
                'other button, so it may be trying to do something.
                ParameterList.ColumnCount = 1
                ParameterList.RowSourceType = "Table/Query"
                ParameterList.RowSource = "SELECT [Sales Reps].[Rep Name] FROM [Sales Reps]"
                
                'This MsgBox does come up, verifying that the branch is taken.
                MsgBox "Sales Rep branch taken."
                
            Case QUERY_BY_YEAR
                'TODO: Complete this option
        End Select
        
    End Sub

  2. #2
    Join Date
    Jun 2009
    Location
    British Columbia, Canada
    Posts
    29
    Issue fixed. I had the first column hidden for my months. Unhiding the first column solved the problem. I would delete the thread but I can't figure out how.

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    It's better to keep the thread with the solution, so that someone else might benefit
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •