Simple Select statement : Recordset Find « Access « VBA / Excel / Access / Word






Simple Select statement

 
Sub MyFirstConnection()
    Dim myConnection As ADODB.Connection
    Dim myRecordset As ADODB.Recordset
    Dim strSQL As String
    
    strSQL = "SELECT * FROM tblCustomer ORDER BY txtCustLastName"
    
    Set myConnection = CurrentProject.Connection
    
    Set myRecordset = New ADODB.Recordset
    myRecordset.Open strSQL, myConnection
    
    Do Until myRecordset.EOF
       Debug.Print myRecordset.Fields("txtCustFirstName"), _
                   myRecordset.Fields("txtCustLastName")
       myRecordset.MoveNext
    Loop
    myRecordset.Close
    myConnection.Close
    Set myConnection = Nothing
    Set myRecordset = Nothing
End Sub

 








Related examples in the same category

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