Find tables used by queries

E

EdStegner

i am a novice at vba. i have written vba code to find the "type" of all
queries in a database. Code was something like:

For each qry in querydefs,
if qry.properties("type") = YYY then do something
Next qry


If the query type = "dqQSelect", i'd like to ascertain what tables are being
used in the select statement. Additionally, if type = dbQAppend, i'd like to
ascertain into what table is having the data is being appended.

Are there properties that can give me this information? there are way too
many queries in this database to do this manually.
 
E

EdStegner via AccessMonster.com

Stuart said:
Correction: the property is called SourceTable, not SourceTableName.
[quoted text clipped - 24 lines]
(untested)
thanks for your time and effort, Stuart, as it is much appreciated. Worked
well but certain query types (e.g. type = dbQAppend) apparently do not have
fields (i.e. qry.Fields.count=0). This seems odd because in design mode, the
query definitely has fields that are being appended to a table.

Perhaps I can restate my original question as follows: When I right-button
click a query and select the "Properties" item, a box appears listing various
properties. The elements displayed vary by query type. Where would this info
be stored? I was thinking it would be buried somewhere in "querydef".
 
Top