Filter a datasheet using a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghost1980
    New Member
    • Feb 2010
    • 5

    Filter a datasheet using a form

    hi there,

    i need your help for a solution and code (if neccessary), to help me to filter a datasheet using a COMBO BOX.

    i have a query, which contain the following example:

    NAME | AGE | COURSE ATTENDING
    John | 29 | DOSH
    Erix | 20 | DOSH
    Alex | 20 | CAT
    Brat | 21 | CAT
    June | 22 | CAT

    i need to find out who are the ones attending DOSH or CAT. i have a large database of names and i need a filter (using combo box) to list out the names that are attending these course using access form. is it possible?

    can you help? much appreciated.
  • hedges98
    New Member
    • Oct 2009
    • 109

    #2
    Do you want the results to display on the form? Or via a report?

    Comment

    • ghost1980
      New Member
      • Feb 2010
      • 5

      #3
      hi there,

      would like it to be displayed on the form. :)

      thanks

      Comment

      • hedges98
        New Member
        • Oct 2009
        • 109

        #4
        Well, this is what I do when I need the same. Create a textbox on your form and set it's Control Source to be the combobox you are using for filtering. Set it's Visible property to No so it is hidden on the form.

        Then, on your query, in the Course Attending field, in the Criteria section set it to be the textbox on that form - it'll be something like
        Code:
        [Form]![YourFormName]![YourTextbox]
        Create a subform on your existing form based on this query. Then, in the After Update event of the combo box you're using, put
        Code:
        Me.YourSubformName.Requery
        and every time you change selection from the combobox, it should update with your filter.

        There is probably a more efficient way to do it but that's what I do!
        Last edited by hedges98; Feb 23 '10, 02:09 PM. Reason: spelling error!

        Comment

        • ghost1980
          New Member
          • Feb 2010
          • 5

          #5
          thank you hedges98. and sorry for the late reply. :)

          Comment

          Working...