querydef with formula

G

Guest

I have written some visual basic scripts to analyze a complex Access 2000
database here at work. I have generated a list of tables and queries and
their corresponding fields.
I am now trying to show the source fields/tables for the fields in my
queries. This works fine except when a field uses a formula. Is there a way
to show the formula that generates a field? I can get the field Name from
the querydef, but don't know where to find the formula portion of the field.

For example, the field in the query is
MonthYear: Format([Date],"mm/yyyy")

CurrentDb.QueryDefs(X).Fields(Y).Name gives me MonthYear. I can't find the
Format([DATE],"mm/yyyy") stored in the querydef.
 
T

Tim Ferguson

CurrentDb.QueryDefs(X).Fields(Y).Name gives me MonthYear. I can't
find the Format([DATE],"mm/yyyy") stored in the querydef.

You'll need to parse out the SELECT part of the SQL of the query. You can
get at the text using QueryDefs("X").SQL but after that it's up to you and
a bunch of Instr() and Mid() functions...

Best of luck!


Tim F
 

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

Similar Threads

DAO queryDef 2
Add where clause to querydef? 1
Invalid Operation on a querydef 2
DoCmd.OutputTo wrong data type 5
recordsets ??? 2
data types 2
QueryDef problem 3
Problem constructing an SQL sentence by code 3

Top