![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am trying to traverse the querydefs collection, to list every field in the query. so far so good. However, some of my queries have calculated fields and I would like to access the definition of the calculation field but do not know how or where it is stored. If fo example I define a new field in a query CalEndDate: IIF(not isnull([Enddate]), [Enddate], #12/31/2999#) I would like to be able to find this definition in the querydef and include it in my report. How do I go about this? Examples? Yes, I have spent hours reading, searching to no joy. thanks Bob |
#3
| |||
| |||
|
|
On 03/02/2011 04:21:12, Bob Alston wrote: I am trying to traverse the querydefs collection, to list every field in the query. so far so good. However, some of my queries have calculated fields and I would like to access the definition of the calculation field but do not know how or where it is stored. If fo example I define a new field in a query CalEndDate: IIF(not isnull([Enddate]), [Enddate], #12/31/2999#) I would like to be able to find this definition in the querydef and include it in my report. How do I go about this? Examples? Yes, I have spent hours reading, searching to no joy. thanks Bob Have you had a look at the MySysQueries Table (normally hidden System Object)? Phil |
#4
| |||
| |||
|
|
I am trying to traverse the querydefs collection, to list every field in the query. *so far so good. *However, some of my queries have calculated fields and I would like to access the definition of the calculation field but do not know how or where it is stored. If fo example I define a new field in a query CalEndDate: *IIF(not isnull([Enddate]), [Enddate], #12/31/2999#) I would like to be able to find this definition in the querydef and include it in my report. How do I go about this? Examples? Yes, I have spent hours reading, searching to no joy. thanks Bob |
#5
| |||
| |||
|
|
On Feb 2, 11:21 pm, Bob Alston<bobalst... (AT) yahoo (DOT) com> wrote: I am trying to traverse the querydefs collection, to list every field in the query. so far so good. However, some of my queries have calculated fields and I would like to access the definition of the calculation field but do not know how or where it is stored. If fo example I define a new field in a query CalEndDate: IIF(not isnull([Enddate]), [Enddate], #12/31/2999#) I would like to be able to find this definition in the querydef and include it in my report. How do I go about this? Examples? Yes, I have spent hours reading, searching to no joy. thanks Bob When parsing the SQL from the SQL property of the QueryDef, note that the 'AS' keyword used to alias the field name can also be used to alias table names. Before the 'AS' keyword you might go back to the first comma or space unless square brackets (or the single quote equivalents used by Lyle Fairfield) are encountered. Maybe see if the parsed field name equates to a table to decide between field and table aliases. Perhaps consider having your parsing cover the alternate syntax used by Jamie Collins to reference tables in other databases. What do you want your reporting to do if you have subqueries? It seems there are possibly many proverbial flies in the ointment. James A. Fortune CDMAPoster (AT) FortuneJames (DOT) com I was hoping to get the data that defines a calculated variable in the |
#6
| |||
| |||
|
|
On 2/3/2011 2:35 PM, James A. Fortune wrote: On Feb 2, 11:21 pm, Bob Alston<bobalst... (AT) yahoo (DOT) com> *wrote: I am trying to traverse the querydefs collection, to list every field in the query. *so far so good. *However, some of my queries have calculated fields and I would like to access the definition of the calculation field but do not know how or where it is stored. If fo example I define a new field in a query CalEndDate: *IIF(not isnull([Enddate]), [Enddate], #12/31/2999#) I would like to be able to find this definition in the querydef and include it in my report. How do I go about this? Examples? Yes, I have spent hours reading, searching to no joy. thanks Bob When parsing the SQL from the SQL property of the QueryDef, note that the 'AS' keyword used to alias the field name can also be used to alias table names. *Before the 'AS' keyword you might go back to the first comma or space unless square brackets (or the single quote equivalents used by Lyle Fairfield) are encountered. *Maybe see if the parsed field name equates to a table to decide between field and table aliases. *Perhaps consider having your parsing cover the alternate syntax used by Jamie Collins to reference tables in other databases. What do you want your reporting to do if you have subqueries? *It seems there are possibly many proverbial flies in the ointment. James A. Fortune CDMAPos... (AT) FortuneJames (DOT) com I was hoping to get the data that defines a calculated variable in the query, from accessing the querydef via DAO and NOT trying to parse the SQL syntax. *I have already gotten several pieces of data from the querydef. *This is just one piece I can't seem to get. Bob |
#7
| |||
| |||
|
|
On 2/3/2011 2:35 PM, James A. Fortune wrote: On Feb 2, 11:21 pm, Bob Alston<bobalst... (AT) yahoo (DOT) com> wrote: I am trying to traverse the querydefs collection, to list every field in the query. so far so good. However, some of my queries have calculated fields and I would like to access the definition of the calculation field but do not know how or where it is stored. If fo example I define a new field in a query CalEndDate: IIF(not isnull([Enddate]), [Enddate], #12/31/2999#) I would like to be able to find this definition in the querydef and include it in my report. How do I go about this? Examples? Yes, I have spent hours reading, searching to no joy. thanks Bob When parsing the SQL from the SQL property of the QueryDef, note that the 'AS' keyword used to alias the field name can also be used to alias table names. Before the 'AS' keyword you might go back to the first comma or space unless square brackets (or the single quote equivalents used by Lyle Fairfield) are encountered. Maybe see if the parsed field name equates to a table to decide between field and table aliases. Perhaps consider having your parsing cover the alternate syntax used by Jamie Collins to reference tables in other databases. What do you want your reporting to do if you have subqueries? It seems there are possibly many proverbial flies in the ointment. James A. Fortune CDMAPoster (AT) FortuneJames (DOT) com I was hoping to get the data that defines a calculated variable in the query, from accessing the querydef via DAO and NOT trying to parse the SQL syntax. I have already gotten several pieces of data from the querydef. This is just one piece I can't seem to get. Bob |
![]() |
| Thread Tools | |
| Display Modes | |
| |