Re: Querydef
- From: "JimP" <jpockmire@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 8 Jun 2008 08:41:59 -0500
I like your last suggestion. I tried the attached code and received the
error "Operation not supported for this type of object". Ideas?
Sub ListQueryObjects()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim fld As DAO.Field
Set db = CurrentDb
Set qdf = db.QueryDefs("CampaignRptSelNews")
For Each fld In qdf
Debug.Print fld.NAME
Next fld
End Sub
"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:eSUWz5JyIHA.4864@xxxxxxxxxxxxxxxxxxxxxxx
Hmm. You want to list the source "tables" that feed a query?
If you are using Access 2003 or 2007, you may be able to trace the
DependencyInfo object back to get the source tables. IME this doens't work
very well: it requires Name AutoCorrect to be turned on (heaps of issues),
and can trying to walk the DependencyInfor can actually crash Access
(typically where some tables/queries refer to objects that no longer exist
in the database), so I can't recommend that approach.
There are some commecial utilities that trace dependencies like that.
Examples:
http://www.speedferret.com/
http://www.rickworld.com/products.html
http://www.fmsinc.com/Products/
If you prefer to trace it yourself, each field in a QueryDef has a
SourceTable, so you could loop the Fields of the QueryDef and examine the
SourceTable of each. Provided the query outputs the field (it may not,
e.g. if it's just used as an INNER JOIN), that should list it, and you can
then discover whether it is a table or query and handle that recursively.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"JimP" <jpockmire@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:NNydnXWv1qoV89fVnZ2dnUVZ_gednZ2d@xxxxxxxxxxxxxx
Thanks, but I think this will give me a listing of the queries in an mdb.
What I want to do is list the tables and/or queries that comprise a
single query.
.
- Follow-Ups:
- Re: Querydef
- From: John Spencer
- Re: Querydef
- References:
- Querydef
- From: JimP
- Re: Querydef
- From: Allen Browne
- Re: Querydef
- From: JimP
- Re: Querydef
- From: Allen Browne
- Querydef
- Prev by Date: Re: Selecting a Combobox Item From VBA
- Next by Date: Re: Querydef
- Previous by thread: Re: Querydef
- Next by thread: Re: Querydef
- Index(es):
Relevant Pages
|
Loading