Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query for Table Field Names then Pass to Variables

Status
Not open for further replies.
May 30, 2004
15
US
I am making an Access form that lets the user create the tables, forms, and queries. I have successfully used command buttons and textboxes that run SQL statements to create tables, set the field definitions, and design the forms. To do most of this I use the Visual Basic code:

DoCmd.RunSQL "[SQL STATMENT GOES HERE]"

However, what I can't figure out is how to make the queries. I need to figure out a SQL query (lets call it "qryTableFieldNames") that will retrieve all of the table field names within a recently created table (lets call it "tblNewTable") and then let me pass those values into a variable.

Does anybody know a SQL statement that retrieves the field names?

I need to create a query based on a table that does not yet exist. Other words, at the same time that the new table is created from using my forms, text boxes, and DoCmd.RunSQL, I want a query to get built simultaneously hat includes the new field names.

Thanks for the help.
 
I don't believe that you can get the field names as an SQL result. I think you would have to open the tabledef and cycle through the fields collection.

Can't you simply use:
Select * from tablename
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top