Programmatically Change Querydef Column Name
Posted on 2005-05-12
I would like to change the column names of the queries in an Access97 database.
A user has used captions instead of aliases for column names and I want to change all of the aliases to the captions.
I've figured out how to find all of the names and all of the captions, but it seems that the Querydef.Field.Name property is Read Only.
There is something about how this Name property is Read/Write if the query is somehow NOT appended to a collection.
I know that I can go through the SQL and hunt for commas and stick in "AS Caption1" type strings into the SQL string, but I was hoping for an easier solution.
Is there a way to temporarily un-append a query from the Querdefs collection in order to change the field names? Or is there a way to create an unappended query? If I can create an unappended query, I could set all of the names and copy the SQL from the appended query to the unappended query or something like that.
Any help would be much appreciated.