J
Joel
I need to run a crosstab query from VBA. One of the columns is a Sum:
Sum(t_TableName.Qty) AS Total
The problem is that I need another column, that has the same value, but
divided by the number of columns that are added by the column header (Sales
Order number). Of course, the number of columns in the result can vary,
depending on how many Sales Orders are input.
I know I could dim a qdf, and use the qdf.Fields().count property, and
subtract the number of fields for the row headers. Let's say the query has 8
columns, 5 row headers and 3 result columns. qdf.Fields().count - 5 tells me
how many Sales Order columns were added, which is 3.
Here's the tricky part....I need to put that "3" (or 4, or 5, if more Sales
Orders are entered) into the denominator of the above query. I tried to
define a parameter (SOCount), and use the qdf.Parameters("SOCount") function
to set the parameter through VBA code. But, that didn't work, since it
re-prompts for the value at run-time. Here's how it looks now:
Sum(t_TableName.Qty)/[SOCount] AS Average
Is there any way I can enter the variable number of columns in a crosstab
query, from the VBA code, with no user interaction, without having to go
through the messy process of passing it as a string variable to the qdf.SQL
string (It's huge!)
Thanks!
Sum(t_TableName.Qty) AS Total
The problem is that I need another column, that has the same value, but
divided by the number of columns that are added by the column header (Sales
Order number). Of course, the number of columns in the result can vary,
depending on how many Sales Orders are input.
I know I could dim a qdf, and use the qdf.Fields().count property, and
subtract the number of fields for the row headers. Let's say the query has 8
columns, 5 row headers and 3 result columns. qdf.Fields().count - 5 tells me
how many Sales Order columns were added, which is 3.
Here's the tricky part....I need to put that "3" (or 4, or 5, if more Sales
Orders are entered) into the denominator of the above query. I tried to
define a parameter (SOCount), and use the qdf.Parameters("SOCount") function
to set the parameter through VBA code. But, that didn't work, since it
re-prompts for the value at run-time. Here's how it looks now:
Sum(t_TableName.Qty)/[SOCount] AS Average
Is there any way I can enter the variable number of columns in a crosstab
query, from the VBA code, with no user interaction, without having to go
through the messy process of passing it as a string variable to the qdf.SQL
string (It's huge!)
Thanks!