Recordset In VBA – PT1

In these next 2 videos, we are going to discuss generating the recordset in VBA techiques:
-We will access data in tables by using the ADO recordset object.
-We will retrieve data from a table using SQL and ADO recordsets.
-We will alter the data in the table using SQL and ADO recordsets.

In this video we are talking about the DAO recordset In VBA and how to formulate one easily.

In my opinion, if you are are programming a desktop database, and are staying in the boundaries of the Jet database engine, use DAO. If you are programming a web based application use ADO.

Private Sub DAORecordset()
    'THIS IS THE EASIEST WAY TO DO THE RECORDSET IN ACCESS
    
    'Declare a variable referencing the object
    Dim rst As DAO.Recordset
    
    'You already have a current database connection.  You have to use the "Set" command & _
        to actually create and use the object

    Set rst = CurrentDb.OpenRecordset("Customers")
    
    rst.MoveFirst
    
    Do Until rst.EOF
        Debug.Print rst.Fields("CompanyName")
        rst.MoveNext
    Loop
    
    'Garbage collection (remove variables from memory)
    rst.Close
    
    Set rst = Nothing
    
End Sub

<< VBA For Loop | Recordset In VBA – PT2 >>

Offsite Related Information:

“Go Fund Me” Page


($5 suggested amount)

(…10% of your gift amount will go to charity)

Free! Subscribe To Our YouTube Channel!

Free MS Access VBA Programming Course

Facebooktwitterredditpinterestlinkedinmailby feather
Tags: ,