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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I print out the Field properties of an Access 2000 Database

Status
Not open for further replies.

TNN

Programmer
Sep 13, 2000
417
US
I am using ADO to connect to an Access 2000 database and using SQL via ADO to work the database.
How do I get a printout of the data base tables and their field contents including the Field properties such as type, size etc.?

I will use the paper printouts as a source to write my SQL statements. Any help is appreciated.

I am programming in VB 6.0

Thank you, Tom, a novice programmer

[sig][/sig]
 
INN,

If you have Ms Access, you can just open the database and look under tools / Analyse / Documentor. Select the category (Tables) and check those which you want the info for. Other options do exist, so if this is not available to you, ask again.

[sig]<p>MichaelRed<br><a href=mailto:mred@duvallgroup.com>mred@duvallgroup.com</a><br>There is never time to do it right but there is always time to do it over[/sig]
 

The best and easiest way to do this is to follow MichaelRed's instructions above. However, if you don't have Access then try this code:

Dim strCnn As String
Dim cnn1 As ADODB.Connection
Dim rs As ADODB.Recordset
Dim f As Field

Set cnn1 = New ADODB.Connection
cnn1.Provider = &quot;Microsoft.Jet.OLEDB.3.51&quot;
cnn1.Open &quot;C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb&quot;

Set rs = New ADODB.Recordset
rs.Open &quot;Select * From Products&quot;, cnn1

For Each f In rs.Fields
With f
Debug.Print .Name
End With
Next

rs.Close
cnn1.Close

Other properties are also available inside the &quot;With&quot; block. Of course, you can change this code to print multiple tables and write out the results to a file rather than using the Debug.Print statement.
[sig][/sig]
 
One of the concepts of a relational database - indeed in the standards set out to define a relational database state this - is that the information about the database is held within the database.

There is a system table called MsysObjects - Tool / Options / View system objects - which holds the names of all tables, queries, reports, ... in the database, in a field called Name. Another field, Type, defines what type of object the record pertains to - 6=table, 5=query, ... - so you could use this to get your list of tables.

Then you can use something like the code in the previous post to get the fields in the tables.

Simon [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top