Solved

Script to read table Def

Posted on 2011-09-11
6
288 Views
Last Modified: 2012-05-12
Hi Experts

Does any one know how to do a script (or has one) that will loop through every field of a given table and retrieve its field name, type and size?

by size, i mean:
  - if type text, size = 15
  - if type = number, size = long
   - if type = yes/no, size = true/false

etc...

Ideally, i'd store this info in a 4-field table (table, name, type, size), and use in a report to print and document.,

Any help will be appreciated
0
Comment
Question by:APD_Toronto
6 Comments
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 36520443
Dim td As DAO.Tabledef
Dim fld As DAO.Field
For Each fld In DbEngine(0)(0).TableDefs("MyTablename").Fields
  Debug.Print fld.Name, fld.Type, fld.Size 
Next

Open in new window

0
 
LVL 77

Expert Comment

by:peter57r
ID: 36521271
You appear to be duplicating what is already available in the database documentor tool
0
 

Author Comment

by:APD_Toronto
ID: 36523249
alkimark, where can I get what the type #s are?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 45

Expert Comment

by:aikimark
ID: 36523426
open up your immediate window and type
?DataTypeEnum.

Open in new window


When you type the period, you should see, courtesy of intellisense, a list of the enum names and values for database field type.

0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 36523510
For a somewhat more elegant report on fields, see my Extras Plus add-in (http://www.helenfeddema.com/Files/code20.zip), a free download from my Website.  One of its menu add-ins creates a nicely formatted report listing all fields in all tables in the current database, either alphabetically or by order in the table:

Table-Fields-Report.jpg
0
 
LVL 75
ID: 36524331
Allen Browne has a good list here:

http://allenbrowne.com/func-06.html

mx
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question