Table names are easy. You can use a simple query:
SELECT DISTINCT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=1));
Table descriptions are a little problematic because unless a table
actually
has a description, the Description property doesn't exist for the table.
(Wierd, I know).
Create a function called TableDescription as follows:
'*********************
Function TableDescription(TableName As Variant) As String
'NOTE: this function requires a Reference to DAO.
On Error GoTo Err_TableDescription
Dim db As DAO.Database
Dim con As DAO.Container
Dim doc As DAO.Document
Dim prp As DAO.Property
Set db = CurrentDb()
Set con = db.Containers("Tables")
Set doc = con.Documents(TableName)
Set prp = doc.Properties("description")
TableDescription = prp.Value
Exit_TableDescription:
Exit Function
Err_TableDescription:
If Err.Number = 3270 Then
TableDescription = "There is no description for this Table"
Resume Exit_TableDescription
Else
MsgBox Err.Description
Resume Exit_TableDescription
End If
End Function
'*********************
Then modify your query as follows:
SELECT DISTINCT MSysObjects.Name, TableDescription([Name]) AS Description
FROM MSysObjects
WHERE (((MSysObjects.Type)=1));
--
--Roger Carlson
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
Brad said:
Thanks for taking the time to read my question.
Just wondering how to return the names and descriptions of all the tables in
the active database using code.
Thanks,
Brad