473,395 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How can I use VB to get Access datbase structure information??


Using Visual Basic with an ADO connection to MS-Access,
I'd like to be able to pull the names of all tables, the
column names in those tables, and the field TYPE
and COMMENT.

I've got the code below to get the Table Names
and Field Names, but don't know how to get
the TYPE and COMMENT information.

Mostly I probably just need the MS-Access Schema
so I know what they are called?

Thanks,
Gary

Dim xRS As New ADODB.Recordset

'----- EXAMPLE #1 FROM MS-WORD DOCUMENTION ABOUT ADO
' LISTS ALL TABLE-NAMES IN THE MDB
'Set xRS = gDBCN.OpenSchema(adSchemaTables)
'Do Until xRS.EOF
' If xRS.Fields("TABLE_TYPE") <> "VIEW" Then
' Debug.Print xRS.Fields("TABLE_NAME")
' End If
' xRS.MoveNext
'Loop
'xRS.Close

'----- EXAMPLE #2 FROM MICROSOFT SITE
' ADAPTED FOR MY MARS MDB - PRINTS ALL COLUMN NAMES FOR WIREORDERS
TABLE
Set xRS = gDBCN.OpenSchema(adSchemaColumns, Array(Empty, Empty,
"WireOrders"))
While Not xRS.EOF
Debug.Print xRS!COLUMN_NAME
Debug.Print xRS!COLUMN_NAME
xRS.MoveNext
Wend
xRS.Close
Nov 13 '05 #1
1 1851

Nevermind - I found it. Will post the code here when
I polish it up a bit. Basically it's just "DESCRIPTIONS" Duh...

Debug.Print xRS!COLUMN_NAME, xRS!Description

"Gary Warner" <ja********@yahoo.com> wrote in message
news:2u*************@uni-berlin.de...

Using Visual Basic with an ADO connection to MS-Access,
I'd like to be able to pull the names of all tables, the
column names in those tables, and the field TYPE
and COMMENT.

I've got the code below to get the Table Names
and Field Names, but don't know how to get
the TYPE and COMMENT information.

Mostly I probably just need the MS-Access Schema
so I know what they are called?

Thanks,
Gary

Dim xRS As New ADODB.Recordset

'----- EXAMPLE #1 FROM MS-WORD DOCUMENTION ABOUT ADO
' LISTS ALL TABLE-NAMES IN THE MDB
'Set xRS = gDBCN.OpenSchema(adSchemaTables)
'Do Until xRS.EOF
' If xRS.Fields("TABLE_TYPE") <> "VIEW" Then
' Debug.Print xRS.Fields("TABLE_NAME")
' End If
' xRS.MoveNext
'Loop
'xRS.Close

'----- EXAMPLE #2 FROM MICROSOFT SITE
' ADAPTED FOR MY MARS MDB - PRINTS ALL COLUMN NAMES FOR WIREORDERS TABLE
Set xRS = gDBCN.OpenSchema(adSchemaColumns, Array(Empty, Empty,
"WireOrders"))
While Not xRS.EOF
Debug.Print xRS!COLUMN_NAME
Debug.Print xRS!COLUMN_NAME
xRS.MoveNext
Wend
xRS.Close

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: middletree | last post by:
I am used to SQL Server, no Access, but this one thing has to be done in Access. Can you tell me if this query will work, based on the syntax? I am trying create a new row on the database, in one...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
6
by: shurstgbr | last post by:
I want to add a number (for example 7.5) to a date. I've been using 365.2425*7.5 and then adding this to the date. This gives an answer that is close and in most cases the error is unnoticeable....
1
by: Torilyn73 | last post by:
Ok folks... I apologize now if I'm covering territory already discussed. I'm sick as a dog right now and have got to get some work done on this datbase. Let me explain what I'm trying to do. I...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
1
by: Sagaert Johan | last post by:
Hi When i add a datacolumn to a dataset and then call Update on the dataset then my MS Access datbase does not reflect the changes.(no coumn was added to the table) DataColumn newcolumn =...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.