By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,572 Members | 2,949 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,572 IT Pros & Developers. It's quick & easy.

ms access table showing table structure

P: 1
I want to generate a table with one record for each field in the tables in my database. Columns would be table name, field name, field type, field description.
I can extract field properties as numeric values, but cannot easioly translate these into meaningful text. I cannot get the field description.
How can I make sense of the field properties programmatically?
Jul 28 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 2.5K+
P: 2,545
Hi, and welcome to Bytes.

The sample code below may give some ideas about accessing table definitions and the fields collection for each table in code. The name property of a field is a string, but its type property is a numeric value mapped to internal VB constants representing each data type (use the help file for the Fields collection to look up the mapping). To map the numeric field type values to their corresponding descriptions you will need to generate the mappings manually, either in code or by a mapping table. For example, the value of the VB constant dbText is 10 and that of dbMemo is 12, so a field of type 10 is a text field (whose size property defines its length) and type 12 a memo field.

I have not found a description property in the fields collection so far.

Expand|Select|Wrap|Line Numbers
  1. Public Function TableData()
  2.     Dim oTableDef As TableDef
  3.     Dim oField As DAO.Field
  4.     For Each oTableDef In CurrentDb.TableDefs
  5.         With oTableDef
  6.             Debug.Print "<" & .Name & ">"
  7.             For Each oField In .Fields
  8.                 With oField
  9.                     Debug.Print .Name, .Type, .Size
  10.                 End With
  11.             Next oField
  12.         End With
  13.     Next oTableDef
  14. End Function
Jul 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.