Filter by multiple combo boxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JC21
    New Member
    • Nov 2006
    • 23

    Filter by multiple combo boxes

    Hi guys,

    I was wondering if someone could give me some insight on this. On a form I would like to have 3 combo boxes which can be used as filters. I would like the information to be displayed on a Subform/Subreport and then be able to print a report. For example Filter1, list the company name. Filter2 list the options (open, close). Filter3 is related to the company acct balance, the options are (<$1000, >$1000, >$5000).
    I would like to be able to select the company, then view only the open or close accts then select what balances I want to view.
    I have created filters on a form before but not on subform. The code I would use for Filter1 and Filter2 is below.

    Private Sub Filter1_AfterUp date()
    Dim strFilter As String
    strFilter = "select * from [Comp_Info] WHERE [CompName]= " & CboName & ";"
    Me.RecordSource = strFilter
    Me.Requery
    End Sub

    To create filter3, I am not sure how to go about doing that. If the code above is good for filters 1 & 2, how do I link the filters so that I can filter from one to the other?
    How should I approach the subform? I was thinking creating a query with all the companies info and then use the filters to view what accounts I want.
    Any help would be greatly appreciated. Thanks in advance.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    You're on the right lines but with your three (unbound) filters, you want to have AfterUpdate event procedures for each but all should call a single procedure (MakeFilter) which would then set up a Filter string (strFilter). There is an example of something similar in (Check Boxes to Pass into Query ).

    Comment

    Working...