query "create table"

A

Allen Browne

samp said:
how can I know from VBA which Data Base is pointing a query
"create table"

I think you are asking how you can tell programmatically which queries are
action queries?

Try something like this:
CurrentDb.QueryDefs("Query1").Type

It should return the value of dbQMakeTable for your 'create table' type
query.

For other values, open the code window, and press F2 to open the Object
Browser. Search for dbQAppend etc.
 
A

Allen Browne

You will need to examine the SQL property of the QueryDef, e.g.:
Debug.Print CurrentDb.QueryDefs("Query1").SQL

It will look something like this:
SELECT Table1.* INTO Table2 IN 'C:\Data\AccessOutput.mdb' FROM Table1;

Parse the string to read the database it is IN.
 
S

samp

it thus:

?Right("SELECT Table1.* INTO Table2 IN 'C:\Data\AccessOutput.mdb' FROM
Table1", InStr("SELECT Table1.* INTO Table2 IN 'C:\Data
\AccessOutput.mdb' FROM Table1","'")+5)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top