Howdy folks! After using the .Find method in ADO, such as
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?Code:myRS.Find "NAME = '" & txtName.Text & "'
Printable View
Howdy folks! After using the .Find method in ADO, such as
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?Code:myRS.Find "NAME = '" & txtName.Text & "'
From the Dao of Pooh...
With ADO fizzle...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
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
I'll give that a whirl, thanks.