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!

How to get Column names from empty table (Desc in Oracle)

Status
Not open for further replies.

desi5pure

MIS
Mar 29, 2008
38
US
How can I get column names from a table that doesn't have any data or has data (just like DESC command in Oravcle)?
 
Here's code that goes thru all of your tables and lists their fields in a table called TestTables. you should be able to tweak it for your needs.

Make a table called TestTables.
Two fields (both text):

TestTableName
TestFieldName


Create a code module and paste this into it:

Code:
Function TableList()
    CurrentDb.Execute ("Delete * from TestTables")
    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("Select * from TestTables")
    
    
    Dim tbf As DAO.TableDef
    Dim fld As Field
        For Each tbf In CurrentDb.TableDefs
           For Each fld In tbf.Fields
                    rs.AddNew
                    rs!TestTableName = tbf.Name
                    rs!TestFieldname = fld.Name
                    rs.Update
            Next fld
        Next tbf
    Set rs = Nothing
End Function

Run the function, look in your table.


Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
You may also consider an ADOX.Catalog object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top