' Does this provider support Seek and Index? If rst.Supports(adIndex) And rst.Supports(adSeek) Then rst.Index = "EmployeeId" ' Display all the employees. rst.MoveFirst Do While rst.EOF = False Debug.Print rst!EmployeeID; ": "; rst!firstname; " "; _ rst!LastName rst.MoveNext Loop
' Prompt the user for an EmployeeID between 1 and 9. rst.MoveFirst Do strID = LCase(Trim(InputBox(strPrompt, "Seek Example"))) ' Quit if strID is a zero-length string (CANCEL, null, etc.) If Len(strID) = 0 Then Exit Do If Len(strID) = 1 And strID >= "1" And strID <= "9" Then rst.Seek Array(strID), adSeekAfterEQ If rst.EOF Then Debug.Print "Employee not found." Else Debug.Print strID; ": Employee='"; rst!firstname; " "; _ rst!LastName; "'" End If End If Loop End If