Finding a Specific Record in a Recordset : Recordset Find « Access « VBA / Excel / Access / Word






Finding a Specific Record in a Recordset

 
Sub FindProject()
    Dim strSQL As String
    Dim rst As ADODB.Recordset
    Set rst = New ADODB.Recordset

    rst.ActiveConnection = CurrentProject.Connection
    rst.CursorType = adOpenStatic
    rst.Open "Select * from Employees"

    'Attempt to find a specific project
    strSQL = "[EmployeeID] = " & 1
    rst.Find strSQL

    'Determine if the specified project was found
    If rst.EOF Then
        msgBox lngValue & " Not Found"
    Else
        msgBox lngValue & " Found"
    End If
    rst.Close
    Set rst = Nothing
End Sub

 








Related examples in the same category

1.Finding the Record Position
2.Change column data case
3.Simple Select statement
4.SQL with where clause
5.Select specific column in select statement
6.Finding Records Using the Find Method
7.Finding a Record Based on Multiple Criteria
8.Find record by using Recordset.FindFirst
9.NoMatch property in Recordset