Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Unanswered: Filtering Subform using Combo box on the main form

    Hi There

    Using Access 2007
    I have a Form and on these Form i have a combo box, which has data from a table in it. this combo box is connected to a field in the subform via table relationships, the subform is called "Data Input Query" and the combo box is called Combo14

    what i want to happen is for the Subform's column to only show the number that i pick from the combo box (e.g i pick 2 in the combo box and want the subform to be filtered so it only shows me records with "2" in the connected field)

    i have a piece of code, show below, the problem with this is that it shows all the data if i choose number 1, but if i choose number 2 or 3 it wont show any records

    Code:
    Private Sub Combo14_AfterUpdate()
    
    
    Me.Data_Input_Query.Form.Filter = " Combo14=1"
    Me.Data_Input_Query.Form.FilterOn = True
    
    End Sub
    can anybody help me out here?

    the combo box only has numbers "1", "2" and "3" and the field it is trying to filter is [Brood Rating]

    I'll attach the database to this message so you'll be able to see my problem
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    I believe you'd have to reverse the order of your code, i.e. set FilterOn to True and then the Filter to whatever. But to be honest, I have no idea what you're trying to do with " Combo14=1"! If you want to Filterby the Combobox Value I would think that you'd simply use

    Filter = Me.Combo14.

    The proper way to do this, I'd think, would be to set the Link Master Fields and Link Child Fields to Combo4 and the Subform's 'connected field,' respectively.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Mar 2012
    Posts
    2
    ahh yes i see that works, but the trouble is, i have another 3 combo boxes that are connected to other fields in the subform, and was hoping i could use some sort of vba code to get each combo box to filter the other fields separately

    However, i cant set a link between each one, because the main form has to be unbound to have all of the combo boxes on it at the same time

Posting Permissions

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