Use seek method in Recordset : Recordset Seek « Access « VBA / Excel / Access / Word

Use seek method in Recordset


Sub UsingSeek()
  Dim rs As ADODB.Recordset
  Dim conn As ADODB.Connection
  Dim strSQL As String
  Set rs = New ADODB.Recordset
  Set conn = CurrentProject.Connection

  With rs
    .Open Source:="Customers", ActiveConnection:=conn, _
      CursorType:=adOpenKeyset, LockType:=adLockOptimistic, _
    .Index = "CompanyName"
    .Seek ("T")
  End With

  Debug.Print rs!CompanyName & " " & rs!ContactTitle & " " & rs!ContactName

End Sub


Related examples in the same category

1.Finding Records Using the Seek Method (Seek constants)
2.Use Do while to loop through until EOF