Change name of column queried "on the fly"

B

Brett D

Hi,
I'm importing multiple tables into an Access DB and performing the same
queries on them. The only problem is that the column names are almost always
different. I want the user to be able to dynamically change the column that
the query is being performed on through a pulldown or text box. I've read
that it can't be done through Access and must be done through VB. I can't
figure out how to create the query! RunSQL won't work (since I'm just doing
SELECT) and I don't know how to create and run a query from within VB.

Please help. Thanks very, very much in advance.
Brett
 
M

MGFoster

Brett said:
Hi,
I'm importing multiple tables into an Access DB and performing the same
queries on them. The only problem is that the column names are almost always
different. I want the user to be able to dynamically change the column that
the query is being performed on through a pulldown or text box. I've read
that it can't be done through Access and must be done through VB. I can't
figure out how to create the query! RunSQL won't work (since I'm just doing
SELECT) and I don't know how to create and run a query from within VB.

Consider using a column name alias. E.g.:

SELECT columnA As Sales, columnB As Receipts ...
 
Top