Error/Prompt when trying to reference a missing column in a table

J

John Mulford

Need a query statement that will not error when trying to reference a missing
column in a table.

Desired Solution:
IIF( NEW_COLUMN does not exist, then use OLD_FIELD, else use NEW_FIELD)

Situation: A new column was added to tables after a specified date.
Query needs to work on old tables that do no contain the column and new
tables
containing the new column without producing an error/prompt.

Desired Solution: A function or any workaround (suppression of the "Enter
Parameter Value" message box, etc.)

Failed Attempts as Prompted for "Enter Parameter Value" message box appears:
IIF( NEW_FIELD is Null, OLD_FIELD, NEW_FIELD) AS SWITCH
IIF( IsError(NEW_FIELD), OLD_FIELD, NEW_FIELD) AS SWITCH

Problem with having the error/prompt is an affect upon automation.

While the statement should produce the desired result if entered through,
prompts can not be passed to other office applications which are actually
calling the query to be executed (Excel).

Thanks for any guidance,
 

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

Top