query "create table"

  • Thread starter Thread starter samp
  • Start date Start date
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.
 
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.
 
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)
 
Back
Top