Results 1 to 5 of 5

Thread: Filter a Recordset?

  1. #1
    Join Date
    May 2003
    Posts
    25

    Question Filter a Recordset?

    I have a form based on a query and specified Link Criteria. When the form opens it displays information based not only on the main query (Filter 1), but also on Link Criteria (Filter 2).

    The count of the underlying recordset (created by Filter 1) equals 79 records but in this case the form displays only 3 records(due to Filter 2).

    I need to loop through the 3 records displayed by Filter 2. In this case, Me.Count currently = 79. How do I add a filter to the actual underlying recordset (Me.Count) so that I weed out all the records except the 3 I want to loop through?

    Any of this make sense?

  2. #2
    Join Date
    Jan 2003
    Location
    UK
    Posts
    277
    Each form has a filter property that you can use to filter down the underlying recordset e.g.

    Me.Filter = "MyID = " & Me.cboSearch
    Me.FilterOn = True

    here i'm filtering a form based on an item chosen in a combobox


    alternatively if you fancy delving into code.......a recordset has a filter property that you can use to open a filtered recordset of a recordset (and you thought your post was confusing)

    take a look at Filter in the help files

  3. #3
    Join Date
    Jun 2003
    Location
    Bloomington, IN, USA
    Posts
    116
    Me.Filter = "MyID = " & Me.cboSearch
    Me.FilterOn = True
    This code works great when in a button click method, however, and I'm not entirly sure why I have to do this and KnooKie doesnt, but when he gave me this code snipit, it didnt work correctly. We had to add the following to get it to work:

    Me.Filter = "MyID = " & chr(34) & Me.cboSearch & chr(34)
    Me.FilterOn = True

    Just throwing it out if you decide to use it.

    Brandon

  4. #4
    Join Date
    Jan 2003
    Location
    UK
    Posts
    277
    The chr(34) bits need adding if you are filtering on a string. If not you don't need them.


    chr(34) = "

  5. #5
    Join Date
    Jun 2003
    Location
    Bloomington, IN, USA
    Posts
    116
    right, ment to explain that one, just kinda slipped my mind.

    Brandon

Posting Permissions

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