Solved

Script to read table Def

Posted on 2011-09-11
6
271 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now