Change name of column queried "on the fly"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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 ...
 
Hi,
Thanks for the reply but I don't understand how that will fix it. Say I've
got the query:
SELECT col1, col2 from myTable;

I want to be able to change, through a listbox or textbox of some sort, col1
and col2 to say col3 and col8. I believe that's not possible in Access; I
have to do it in VB. I was wondering what the easiest way to do it is.

Thanks very much,
Brett
 

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

Similar Threads


Back
Top