By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,152 Members | 2,576 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,152 IT Pros & Developers. It's quick & easy.

help with using recordsets - i'm a beginner!

P: 27
I am trying to use a recordset for the first time with a query as itís source. I am having trouble getting it to work. I've been quite sucessful with other VB scripting.

My motivation for doing so is that I would like to use a recordset instead of a temporary table for storing some temporary data that will be used to perform some data manipulation.

Can anyone give me some instructions on how to do this using DAO? Iíve read what I can regarding DAO and ADO, and it seems like DAO is the best option at the moment.

Thank you for any guidance that can be provided!
Dec 11 '06 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,616
Try looking here (Microsoft Access Tips for Serious Users).
Dec 11 '06 #2

P: 27
that is helpful, but how do you use a query as part of a recordset source?
Dec 11 '06 #3

NeoPa
Expert Mod 15k+
P: 31,616
that is helpful, but how do you use a query as part of a recordset source?
You include the QueryDef name in some SQL in a string which is passed as a parameter to the OpenRecordset function.
Dec 11 '06 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
that is helpful, but how do you use a query as part of a recordset source?
Expand|Select|Wrap|Line Numbers
  1. Dim db As Database
  2. Dim rs As DAO.Recordset
  3. Dim strSQL As String
  4.  
  5.    Set db = CurrentDb
  6.  
  7.    strSQL = "SELECT .....etc."
  8.    Set rs = db.OpenRecordset(strSQL)
  9.  
  10.    'Your code here
  11.  
  12.    rs.close
  13.    Set rs = Nothing
  14.    Set db = Nothing
  15.  
Alternatively if your query is predefined ....

Expand|Select|Wrap|Line Numbers
  1. Dim db As Database
  2. Dim rs As DAO.Recordset
  3.  
  4.    Set db = CurrentDb
  5.    Set rs = db.OpenRecordset("QueryName")
  6.  
  7.    'Your code here
  8.  
  9.    rs.close
  10.    Set rs = Nothing
  11.    Set db = Nothing
  12.  
Mary
Dec 11 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.