[AccessD] ListFields function

Charlotte Foust cfoust at infostatsystems.com
Tue Dec 30 10:24:29 CST 2003


Here's something from on-line help that does it for all tables:

Charlotte Foust


'***** Code Begins **************
Private Sub cmdSchema_Click()

Dim adoConnection As ADODB.Connection
Dim adoRsFields As ADODB.Recordset
Dim sConnection As String
Dim sCurrentTable As String
Dim sNewTable As String

Set adoConnection = New ADODB.Connection

sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\BegDB\Biblio.mdb"

adoConnection.Open sConnection

Set adoRsFields = adoConnection.OpenSchema(adSchemaColumns)

sCurrentTable = ""
sNewTable = ""

Do Until adoRsFields.EOF
  sCurrentTable = adoRsFields!TABLE_NAME
  If (sCurrentTable <> sNewTable) Then
    sNewTable = adoRsFields!TABLE_NAME
    Debug.Print "Current Table: " & adoRsFields!TABLE_NAME
  End If
  Debug.Print "   Field: " & adoRsFields!COLUMN_NAME
  adoRsFields.MoveNext
Loop

adoRsFields.Close
Set adoRsFields = Nothing
adoConnection.Close
Set adoConnection = Nothing

End Sub
'********Code Ends***************

-----Original Message-----
From: Arthur Fuller [mailto:artful at rogers.com] 
Sent: Tuesday, December 30, 2003 11:08 AM
To: AccessD
Subject: [AccessD] ListFields function


Anyone got a sub that lists the fields of a specified table? I just want
something to dump the names into the debug window. Not hard to write but
I'm hoping someone can just cut and paste.

TIA,
Arthur


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list