Change Destination Table in QBE from VBA

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

Guest

I have a QBE that is a make table query and it makes a
table in an external database. I want to be able to use a
parameter to supply the destination database name. I do
not want to use a sql string but rather want to use the
following code - DoCmd.OpenQuery "myQuery" - without
defining a QueryDEF or creating the query.

For some reason the query runs faster if I do not use a
QueryDEF or try to execute a SQL String. I have performed
multiple test and cannot figure out why (but that is
another issue).



Regards,
JohnV
 
John,

Could it be, in your case, that the saved query executes
more quickly because Access transparently saves an
execution plan with saved queries?

I don't know how you can achieve your objective without
recreating the query or SQL in code - in which case,
as you seem to have found, it will run more slowly. Usually,
the only parameters you'd pass to a query are values to
complete a query's criteria. You want to fundamentally
change the action of the query, which I think means you
will need to re-create it or re-create an SQL, substituting
a variable for the destination table name in the SQL string.
I've never tried that for an external database, but I imagine
it's possible.

Geoff
 
Back
Top