Cross posted here:
http://stackoverflow.com/questions/1...ield-parameter

I am using ADO to retrieve data from MS Access into Excel, and I want to append an Iif statement into the SELECT part of my query. My SQL string is stored in a text file, and any parameters are being appended via ADO.

I know how to append parameters in the WHERE clause, and can even append parameters in the SELECT statement like this:

Code:
SELECT BA, Iif(QA=[@somestring],[@somestring2], [@somestring3])
FROM myData
WHERE BA = 'some person'
But what I am trying to accomplish is to transform a placeholder [@somestring] into a variable length Iif statement, such as:

Code:
SELECT BA, [@somestring]
And the placeholder translates to a string I have built using a function:

Code:
Iif(QA='Jon Doe', 'Jon', Iif(QA='Jane Doe', 'Jane', 'Nobody')).
Right now, the result I get is the literal string I pass to the parameter populating the entire field. So the Iif statement is literally written out for each record, rather than being evaluated by SQL.

Is what I am trying to do even possible, or does SQL need the Field for the Iif statement predefined in the initial command?

ie,
Code:
Iif(QA=[@somestring], [@sometstring2], [@somestring3])