J
JimP
Is it possible to list all of the tables/queries in a query via code?
Allen Browne said:Did you try the suggestion of using the SourceTable?
In John's code:
Debug.Print fld.Name & " = " & fld.SourceTable & "." & fld.SourceField
You're right.
The table in this case is a temp table of "alpha codes" created from a
multi-select list box on a form. The routine that creates the tables,
converts all codes to lower case to eliminate the possibility of duplicates.
The temp table in turn links to SQL Server tables to extract data. Some of
the SQL Server tables have a mixture of upper/lower case codes.
I need to find which queries have the temp table to edit the SELECT
statement to force lower case joins (to many queries to manually inspect) -
case sensitivity is enabled.
I didn't design the SQL Server db. Ms-Access is just being used as a report
writer and I'm trying to assure that the table joins in queries are correct.
Jim
[quoted text clipped - 7 lines]Jim, I dont' follow that.
The following will provide a listing of all queries and their sources. If
the
source is another query, you'll need to scroll to that query to see the
table(s) as source.
One problem I've been unable to resolve: If the query is a SELECT Top
the number provided will show up in the Source column. I've attempted
to resolve this using the Val() function, i.e. if the Source is a number,
that will appear as a number, if not it'll show as 0. The intent is to
filter on the field (Expr1), select only those records with Expr1 = 0,
however this returns 'Data Type Mismatch in Criteria Expression'.
Have done several searches where posters have described this problem
but none of them have resulted in a successful solution, other than a
response that 'the Val function should work'.
SELECT DISTINCT
A.Name AS Query
, B.Name1 AS Source
, Val([Name1]) AS Expr1
FROM
MSysObjects AS A
, MSysQueries AS B
WHERE
(((A.Id)=.[ObjectID])
AND
((B.Expression) Is Null)
AND
((Left([Name],1))<>'~')
AND
((Left([Name1],1))<>'['))
ORDER BY
A.Name
, Val([Name1]);ob
HTH - Bob
[quoted text clipped - 18 lines]You're right.