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

Easy one

P: n/a
I can't figure out how to run a selection sql-query from vb code that was
already implemented in the query guide thing, for instance if my query's
name is findMyRecords, then I would want something like set rs =
currentDb.OpenRecordset(findMyRecords), but that doesn't work of course. I'm
using Access 2003. Tried the help file and all....Really lost I am.
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Set rs = CurrentDb.OpenRecordset("findMyRecords")

Without the quotes, VBA will assume that findMyRecords is the name of a
variable.

It will usually be better, though, to declare a variable and assign a
reference to CurrentDb to the variable, so that you can control the scope
and lifetime of the reference.

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("findMyRecords")

--
Brendan Reynolds

"Vegard H. Villmones" <vv******@c2i.net> wrote in message
news:nE******************@news2.e.nsc.no...
I can't figure out how to run a selection sql-query from vb code that was
already implemented in the query guide thing, for instance if my query's
name is findMyRecords, then I would want something like set rs =
currentDb.OpenRecordset(findMyRecords), but that doesn't work of course. I'm using Access 2003. Tried the help file and all....Really lost I am.

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.