This uses DAO, you may need to go to Tools|Refernces in the code editor and
check the box next to DAO, depending on your version of Access.
Dim rst As DAO.Recordset, strSQL As String
strSQL = "SELECT ....." 'fill in the rest of your query statement
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
'manipulate the recordset here to do what you want
rst.Close
Set rst = Nothing
Lookup the Recordset Object in the code editor's help to get the methods and
properties available for the object.
If you setup the linked table already...then here is an example. In this
folwing case, table contacts is on sql server..but is linked...
'An example DAO vs ADO recordset loop, you'll see how similar they are:
'--- begin DAO ---
Dim rst As dao.Recordset
Set rst = CurrentDb.OpenRecordset("select * from contacts")
Do While rst.EOF = False
Debug.Print rst!FirstName
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
'--- end DAO ---
'--- begin ADO ---
Dim rs As New ADODB.Recordset
rs.Open ("select * from contacts"), CurrentProject.Connection
Do While rs.EOF = False
Debug.Print rs!FirstName
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.