Hello,
I have form with 12 buttons that are calling 12 queries. I'm trying to
have
only one query instead of 12 as all queries are the same except some of
the
field names (column names) in the SELECT statement.
I was trying to create a function with SELECT Case statement in VBA that
would change these field names depending on which button was clicked.
However,
the function is returning name of the field (column name) as string. So,
when
I run the query, instead of values of the specified column name, I receive
the returned column name in each row.
My problem is that I don't know how to return that field name(column name)
as
the field name not as a string.
Please HELP. Also, if you have any other suggestions on how to make one
query
out of 12 will be appreciated.
The following is the query that i try to modify:
SELECT [Global Form Table].[Entity Name],
dbo_ldr_acct_bal.ldr_entity_id, dbo_ldr_acct_bal.centre, dbo_ldr_acct_bal.
account, dbo_ldr_acct_bal.product, dbo_ldr_acct_bal.market, dbo_ldr_acct.
acct_type_code, dbo_ldr_acct.acct_descp_1, dbo_ldr_acct.acct_descp_2,
dbo_ldr_acct_bal.curr_type, dbo_ldr_acct_bal.curr_code, Get_Period() AS
acur
FROM [Global Form Table] INNER JOIN (dbo_ldr_acct_bal LEFT JOIN
dbo_ldr_acct
ON (dbo_ldr_acct_bal.market = dbo_ldr_acct.market) AND (dbo_ldr_acct_bal.
product = dbo_ldr_acct.product) AND (dbo_ldr_acct_bal.account =
dbo_ldr_acct.
account) AND (dbo_ldr_acct_bal.centre = dbo_ldr_acct.centre) AND
(dbo_ldr_acct_bal.ldr_entity_id = dbo_ldr_acct.ldr_entity_id)) ON [Global
Form Table].GTNIEntity = dbo_ldr_acct_bal.ldr_entity_id
GROUP BY [Global Form Table].[Entity Name],
dbo_ldr_acct_bal.ldr_entity_id,
dbo_ldr_acct_bal.centre, dbo_ldr_acct_bal.account,
dbo_ldr_acct_bal.product,
dbo_ldr_acct_bal.market, dbo_ldr_acct.acct_type_code, dbo_ldr_acct.
acct_descp_1, dbo_ldr_acct.acct_descp_2, dbo_ldr_acct_bal.curr_type,
dbo_ldr_acct_bal.curr_code
HAVING (((dbo_ldr_acct_bal.centre)>=[From Department] And
(dbo_ldr_acct_bal.
centre)<=[To Department]) AND ((dbo_ldr_acct_bal.account)>=[From Account]
And
(dbo_ldr_acct_bal.account)<=[To Account]) AND
((dbo_ldr_acct_bal.curr_type)
="B1") AND ((dbo_ldr_acct_bal.curr_code)="CAD"));


|