Full Version: Display attributes for a table
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
turtlpc
Within a form I am building the enduser a view of the existing tables I created within access. When the user clicks on a table name in a list object I want to show the attributes of the table (field names, data types and field size). What I'd like to know is how do I get the attributes in a query?

I'm pulling the tables names using the following query;

SELECT [MSysObjects].[Name], Left([DateCreate],10) AS Created, Left([DateUpdate],10) AS [Last Update] FROM MSysObjects WHERE ((([MSysObjects].[Type])=1)) ORDER BY [MSysObjects].[Name];

Thanks for any and all assistance,

Phill
fkegley
I don't know if what you want can be done with a query, here's some code to do it:

Dim db As DAO.Database
Dim td As DAO.TableDef
Dim f As DAO.Field

Set db = CurrentDb()
For Each td In db.TableDefs
If Left(td.Name, 4) <> "MSys" Then
Debug.Print td.Name
For Each f In td.Fields
Debug.Print f.Name
Debug.Print f.Type
Debug.Print f.Size
Next f
End If
Next td
Set db = Nothing

I have printed it to the debug window, but you could just as easily put it into a form.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.