Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Evansville, Indiana, USA
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Filter List (2007)

    I have a list on my form. The row source of the list box is:

    SELECT quPOlistbox.[PO#], quPOlistbox.[Generated PO], quPOlistbox.[Customer Name], quPOlistbox.Submitted, quPOlistbox.Rejected, quPOlistbox.[Approved Boss], quPOlistbox.[Approved Pay], quPOlistbox.[IE]
    FROM quPOlistbox
    ORDER BY quPOlistbox.[Customer Name], quPOlistbox.[PO#];

    I also have a group of radio buttons that I want to filter the list based on which radio is selected. The radio will select I or E, which will filter based on quPOlistbox.[IE]. Any suggestions?
    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filter List (2007)

    You can change the Row Source of the list box in the After Update event of the option group containing the radio buttons. Let's say that the option value for "I" is1 and that for "E" is 2.
    <code>
    Private Sub MyOptionGroup_AfterUpdate()
    Dim strSQL As String
    If Me.MyOptionGroup = 1 Then
    strSQL = "SELECT [PO#], [Generated PO], [Customer Name], Submitted, Rejected, [Approved Boss], [Approved Pay], [IE] " & _
    "FROM quPOlistbox WHERE [IE] = 'I' ORDER BY [Customer Name], [PO#]"
    Else
    strSQL = "SELECT [PO#], [Generated PO], [Customer Name], Submitted, Rejected, [Approved Boss], [Approved Pay], [IE] " & _
    "FROM quPOlistbox WHERE [IE] = 'E' ORDER BY [Customer Name], [PO#]"
    End If
    Me.MyListBox.RowSource = strSQL
    End Sub</code>

  3. #3
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Evansville, Indiana, USA
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filter List (2007)

    Hans,
    Will I need to add a requery at the end of the sub to update the list?
    Thanks,

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filter List (2007)

    I don't think so, but you will find out soon enough when you try it.

  5. #5
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Evansville, Indiana, USA
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filter List (2007)

    That is much easier than the way I was doing it. <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35> I was setting a invisible textbox on the form and then basing my query off of the value in the textbox. <img src=/S/confused3.gif border=0 alt=confused3 width=45 height=45> Thanks for the help.

Posting Permissions

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