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

Get recordset from an open query window

P: n/a
Is it possible to get the recordset from an open query window? So you
run the query. The window is open. Can vba retrieve this data?
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
It is possible to create a recordset based on the query, but if the records
have changed since you opened the window then the recordset would reflect
those changes. What are you trying to do by doing this?

--
Wayne Morgan
Microsoft Access MVP
"Ryan Hubbard" <ry******@yahoo.com> wrote in message
news:ab**************************@posting.google.c om...
Is it possible to get the recordset from an open query window? So you
run the query. The window is open. Can vba retrieve this data?

Nov 13 '05 #2

P: n/a


I'm writing a script for a friend and he wants to be able to run queries
then from the open queries run a vb script that will manipulate data
only on open queries. I know there may be better ways but thats what he
wants. I don't care about wether or not the data has changed I just
want to be able to get the data from the open window. Any thoughts on
how I would go about doing this? Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

P: n/a
Queries don't have scripts. Forms are designed for doing this. Create a form
using the query as its Record Source. You can then refer to the form's
recordset in the event procedures for the form and/or its controls.

Me.Recordset, etc.

To simply open a recordset in code using DAO:
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("qryMyQuery", dbOpenDynaset)

--
Wayne Morgan
Microsoft Access MVP
"Ryan Hubbard" <ry******@yahoo.com> wrote in message
news:41**********************@news.newsgroups.ws.. .


I'm writing a script for a friend and he wants to be able to run queries
then from the open queries run a vb script that will manipulate data
only on open queries. I know there may be better ways but thats what he
wants. I don't care about wether or not the data has changed I just
want to be able to get the data from the open window. Any thoughts on
how I would go about doing this? Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #4

P: n/a


Please bare with me here for a sec. I thank you for all your help but I
know queries don't have scripts I'm actually a very experienced vba
programmer. But the script will be run independently of the queries. I
also know how to open a query but please assume there is no way around
the situation, which is there are open query windows already which you
need to extract the data from. You then run a vb script, can the vb
script access the query data which is already open. An example of when
you can't just open a record set for a query is if it has parameters.
Parameters which have already been given when the individual has run the
query for the query window. Open the record set via the OpenRecordset
does not open the record set from the open query instead runs the query
again and will expect parameters. So is there a way to access the
results for a query that is already open in a window?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #5

P: n/a
Ryan,

I see what you're getting at. I don't know of a way. The only thing I can
think of would be to control the user opening the query in that fashion in
the first place. Usually, the user shouldn't have access to the main
database window where they could just click on a query and open it. If you
used a form to allow them to open the query, you could put the parameter
prompts on the form (and therefore capture them) and not let them click the
button to open the query until the parameters had been filled in.

That being said, if you open a Report based on a query that prompts for
parameters, you can use the "names" of the parameters in the report and it
will pick up the values that were entered. However, again, the user didn't
directly open the query, the query was opened by opening the report.

--
Wayne Morgan
Microsoft Access MVP
"Ryan Hubbard" <ry******@yahoo.com> wrote in message
news:41**********************@news.newsgroups.ws.. .


Please bare with me here for a sec. I thank you for all your help but I
know queries don't have scripts I'm actually a very experienced vba
programmer. But the script will be run independently of the queries. I
also know how to open a query but please assume there is no way around
the situation, which is there are open query windows already which you
need to extract the data from. You then run a vb script, can the vb
script access the query data which is already open. An example of when
you can't just open a record set for a query is if it has parameters.
Parameters which have already been given when the individual has run the
query for the query window. Open the record set via the OpenRecordset
does not open the record set from the open query instead runs the query
again and will expect parameters. So is there a way to access the
results for a query that is already open in a window?

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.