acCmdQueryTypeMakeTable

  • Thread starter Thread starter Anna
  • Start date Start date
A

Anna

I'm trying to use code to copy a select query, then turn
the copy into a Make Table query. So far I have:


DoCmd.CopyObject , "tmpQuery", acQuery, Reports
(0).RecordSource

DoCmd.SelectObject acQuery, "tmpQuery"
DoCmd.RunCommand acCmdDesignView

Then I'm trying to change the query to a Make Table type
using acCmdQueryTypeMakeTable like so:

DoCmd.RunCommand acCmdQueryTypeMakeTable

But I have no idea how I'm supposed to specify the name of
the table the query is supposed to create. Any
suggestions?
 
Hi,

You could simply create a Make-Table query with your "tmpQuery" query as the
source without going through the extra steps.
 
Not sure what you mean. The "tmpQuery" is a copy of a
select query that is the record source for an open
report. The idea is make a copy of the report's source
query, change that copy from a Select Query into a Make
Table query, then point report's record source to that new
table as it's new record source. The fact that the
current record source is a query (and a complex one at
that) is causing trouble for a report filter I'm trying to
create. So I have to make the record source into a table
before I run the filter.
 
Here's what I meant:

'Make your table from the original query:
MyDB.Execute "Select * Into tblNewTable From qryQueryForReport"

'Change the recordsource within the open report:
Me.RecordSource = tblNewTable

No need for a temp query in the middle.
 
Back
Top