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