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 >>




By the way, if you got or are getting value from the VBA information, please give me a tip, thanks!


These posts may help answer your question too...

How To Parse A Flat File In Excel VBA

In another post I demonstrated how to access a file on your computer using the MS Office Library. Here it is if you don’t know what I’m talking about. In this post, I am going to show you how to access the file and load it into your spreadsheet. I will do the same thing […]

How can I interact with other Office applications (Excel) using VBA in Access?

Need to write your Access data or query to an Excel file? Here is the how to do it: Most people are familiar with Excel and know how to use it well (enough), and when you start talking about Access, they get scared off, and don’t know what to do anymore. Well, here you are […]

How To Generate A XML File With Access VBA

XML is used to structure your data. You can send a CSV file to another person, but using XML, you can structure your data in a more elegant format, and get very specific about your fields, and what data is contained within your tags (your field names). This is different than a basic CSV file […]

Mouse Click Counter On Access Form

This post will demonstrate how you can count the number of clicks on your button in a certain time frame. It will function like a game . Here is the database form all in one: Option Compare Database Public m_dteStartTime As Date Public m_dteStopTime As Date Private Sub btnClicker_Click() Dim intValue As Integer Dim rst […]

Previous Post

Recordset In VBA – PT2

Next Post

VBA For Loop

Leave a Reply

Your email address will not be published. Required fields are marked *