Results 1 to 3 of 3

Thread: searching records in ADO

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Question

    Howdy folks! After using the .Find method in ADO, such as
    Code:
    myRS.Find "NAME = '" & txtName.Text & "'
    how does one determine whether or not a match was found? I guess I am spoiled by DAO's .NoMatch property. Is their something similar in ADO?

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    From the Dao of Pooh...
    Code:
    Sub DAOFindRecord()
    Dim db As DAO.Database, rst As DAO.Recordset
        ' Open database
        Set db = DBEngine.OpenDatabase("C:\nwind.mdb")
        ' Open the Recordset
        Set rst = db.OpenRecordset("Customers", dbOpenDynaset)
        ' Find first 
        rst.FindFirst "NAME = '" & txtName.Text & "'"
        ' Do somethin mit DAO Finds...
        While Not rst.NoMatch
            Debug.Print rst.Fields("CustomerId").Value
            rst.FindNext "NAME = '" & txtName.Text & "'"
        Wend
        rst.Close
    End Sub
    With ADO fizzle...
    Code:
    Sub ADOFindRecord()
    Dim cnn As New ADODB.Connection, rst As New ADODB.Recordset
       ' Open connection
        cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\nwind.mdb;"
       ' Open recordset
        rst.Open "Customers", cnn, adOpenKeyset, adLockOptimistic
       ' Find first
        rst.Find "NAME = '" & txtName.Text & "'"
       ' Do with ADO finds...
        While Not rst.EOF
            Debug.Print rst.Fields("CustomerId").Value
            rst.Find "NAME = '" & txtName.Text & "'", 1
        Wend
        rst.Close
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    I'll give that a whirl, thanks.

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