Results 1 to 3 of 3

Thread: How to user Filter with a RecordSet?

Hybrid View

  1. #1

    Thread Starter
    Addicted Member Michel Jr's Avatar
    Join Date
    Jan 2000
    Location
    Brazil
    Posts
    175

    Question

    Hi,

    I have been populating a RecordSet with all the records of a table:

    Set Rst = New ADODB.Recordset
    wSQL = "Select * from CUSTOMERS Order by CustName"
    Rst.Open wSQL, Conn, adOpenDynamic, adLockOptimistic

    How can I find a specific record in this RecordSet using the Filter method?

    Note: If I find the record I'm looking for, I need to delete it and move the pointer of the RecodSet to the Next record or Previous record.
    I can't re-populate the RecordSet every time I delete a record (it has a lot of records and I think this would be a little slow).

    I think that the Filter method is the best way to solve this, but how to use it?

    Thanks in advance...

    Michel Jr.

  2. #2
    Addicted Member morphman2000's Avatar
    Join Date
    Oct 2000
    Location
    Europe, The Netherlands
    Posts
    254

    Question

    Why don't you just refine your query to it?

    Like this:

    Code:
    Set Rst = New ADODB.Recordset 
    wSQL = "Select * from CUSTOMERS where CustName = ' Michel'  Order by CustName" 
    Rst.Open wSQL, Conn, adOpenDynamic, adLockOptimistic
    You recordset will only contain the records which contain Michel in the field 'CustName'.

    easy...

    Big benefit is that your recordset is not so big.

  3. #3
    Hyperactive Member
    Join Date
    Feb 2000
    Posts
    284
    Not that I don't have the same concerns as Morphman2000

    Rst.Filter = "CustName = '" & varName & "'"

Posting Permissions

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



Click Here to Expand Forum to Full Width