Results 1 to 10 of 10
  1. #1
    zozzz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    49

    filter listbox with another listbox

    hi everyone
    As you can see in the picture I have 3 List boxes and I want to when choose the first list ، Filtered the second list box automatically.


    Thank you for your help

    Click image for larger version. 

Name:	555.png 
Views:	20 
Size:	64.1 KB 
ID:	41861

    Listbox filtering.zip

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The query assigned to list 2 & 3 uses the other listbox as criteria.
    lst2 uses lst1

    Q2:
    select code from table where country=forms!fMyForm!lst1

    then refresh the list once user picks an item:
    Code:
    sub lst1_afterupdate()
     lst2.requery
    end sub

  3. #3
    zozzz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    49
    excuse me my friend. can you complete the sample ?

    why dos not work this code??????
    Private Sub List2_Click()
    Dim sql As String
    sql = "SELECT Contry FROM tbl1 WHERE Contry Like '*" & List2.Column(0) & "' ORDER BY Contry"
    Me.List4.RowSource = sql
    Me.List4.Requery
    End Sub

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725

  5. #5
    zozzz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    49
    your example for the combo box

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725

  7. #7
    zozzz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    49
    thanks orange

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by zozzz View Post
    your example (is) for the combo box
    That's correct...but Listboxes and Comboboxes work in the exact same way, in this situation...as long as Multi-Select Property for the Listbox is set to None.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I agree 'linq that's why I showed the FMS combobox example. I provided a cascading listbox using the OP's data, since he/she seemed adamant to use a Listbox. As you say, either will work if one 1 selection is made.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-21-2017, 12:31 AM
  2. Replies: 2
    Last Post: 03-23-2014, 06:50 AM
  3. Replies: 3
    Last Post: 12-13-2012, 04:40 AM
  4. Replies: 1
    Last Post: 09-10-2012, 11:21 PM
  5. Replies: 1
    Last Post: 07-26-2012, 11:45 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