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


Sign Up For A FREE MS Access VBA Video Tutorial Subscription. You will get over 27 tutorial videos that will help you do your job better! Start Yours Now At:
http://vbahowto.com/ms-access-tutorial








