DoCmd.Openquery question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

After read other posting and trying a few suggestions and getting no where I
was hoping that someone could help me out.

I am trying to do a DoCmd.Openquery but do not want the table to open. I
have over a 50 different queries i.e. select, crosstab, make tables that are
limited by the users select on the form that outputs a report.

When doing the following it takes way to long to run but produces the
correct output.

DoCmd.Openquery "qTest1"
DoCmd.Close

I tried DoCmd.Requery (qTest1) which runs very quickly but when the user
select new limits from the form it doesn't update the limits since its a
requery and just reruns the old query limits. I also tried Execute =
"qTest1" which has the same results as the requery.
With my db CurrentDb then tried doing the following with no luck
CurrentDb.QueryDefs("qTest1").Execute dbFailOnError because you can't exceute
a select statement.

Is there anyway to do a DoCmd.openquery but having it run like a requery
where it doesn't open any tables.

Thank you
 
Why are you running the query if you don't want to see the results, and the
query is not an action (e.g., Update, Delete) query?
 
I am running a report at the end. So I would like to just display the report.

I ended up having to do multi make table query's because i couldn't do a
crosstab query using the limits from the forms. So now I have a bunch of
query's that I am running to make the final output query that is used to
display the values in the report.
 
Action queries can be run via DoCmd.RunSQL action, or by CurrentDb.Execute
action.

If the report is based on a select query, then there's no need to run the
query before you open the report. The report will run the query itself.
 
Back
Top