Results 1 to 2 of 2
  1. #1
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts

    Filtering List Box Contents

    Hey Y'all,

    I'm trying to create a tabbed form that takes it's record from a List Box. This part works.
    What I'd also like to do is to filter the List Box contents by selecting a language type so that the List Box will only show titles that match the filter.
    AccessFilter.JPG
    This works halfway! The filter is initiated and only Titles with the matching language type can be selected from the List Box but ALL titles still show in the List Box!

    Code to establish the filter:
    Code:
    Private Sub lboxSyntaxTypes_AfterUpdate()
    
       With Me
           .FilterOn = False
           If .lboxSyntaxTypes = "ALL" Then
           Else
             .Filter = "[SyntaxType]= " & Chr(34) & Me.lboxSyntaxTypes & Chr(34)
             .FilterOn = True
           End If
       End With
       
       Form_frmCodeTab.Requery
       
    End Sub
    
    Any Ideas? :cheers:
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Hey Y'all,

    I got it!
    Code:
    Private Sub lboxSyntaxTypes_AfterUpdate()
    
       With Me
           .FilterOn = False
           If .lboxSyntaxTypes = "ALL" Then
             .lboxTitle.RowSource = "SELECT Title FROM SourceCode;"
           Else
             .Filter = "[SyntaxType]= " & Chr(34) & Me.lboxSyntaxTypes & Chr(34)
             .FilterOn = True
             .lboxTitle.RowSource = "SELECT Title FROM SourceCode Where [SyntaxType] Like '" & Me.lboxSyntaxTypes & "';"
           End If
       End With
       
       Form_frmCodeTab.Requery
       Me.lboxTitle.Selected(0) = True
      
    End Sub
    Maybe this will help someone else!
    Last edited by RetiredGeek; 2015-03-17 at 20:16.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

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