PDA

View Full Version : Solved: Get Table Column Names - Only



asingh
06-18-2007, 02:35 AM
Hi,

I need help to sort out the following logic...

I have a certain table : tbl_all_data, which has columns...a,b,c,d,e,f,g.

I want to create a list box, which displays the names of these columns from tbl_all_data. So when the users chooses....a,d,g.....I pull only columns...a,d,g from tbl_all_data.

What I have thought of so far....

1. How do I get the columns names for tbl_all_data. Once I can isolate the column names I can push those names into another storage table. And display these values on the list box.

2. Once the user makes a choice of a,d,g...I again push these three names into another storage table.

3. Then I run a DLL query....CREATE TABLE new_data (a TEXT, d TEXT, g TEXT)...this will create a holding table for my new data.

4. ThenI run a SELECT query based on my Column Selection. I do not remember the exact syntax, but Access-VBA allows you to dynamically feed the columns name as a variable and run the select. I Append the output of this select into the new_data table.

Problem:

How do I just get the columns names for the tbl_all_data. Meaning dynamically..since the column names for tbl_all_data can vary, depending on some processing which has happened, prior to the column selection by the user....!

Let me know the best way to do this....or if my logic..is inconsistent...!


thanks a lot for the help...

regards,

asingh

Ebrow
06-19-2007, 02:49 PM
Hey.

Here is an example to try. Is this what you are looking for? Let me know what you think. Not the best coding standards sorry.

6044

asingh
06-19-2007, 06:06 PM
Hi,

thanks Eybrow for the solution..it seems to work. Really liked the way you constructed the SELECT statement.

I found an alternate way to read the table column names.

Check this out too:
Alernate_Solution_to_Get_Access_Column_Names (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1709040&SiteID=1)

Marking this thread as solved...!

thanks a lot,

regards,

asingh