[AccessD] OpenSchema syntax

Gustav Brock Gustav at cactus.dk
Mon Mar 13 08:05:33 CST 2006


Hi Susan

But that _is_ for a specific table: Shippers.

In general:

Public Sub GetTablesFields()

  Dim cnn   As ADODB.Connection
  Dim rstTbl As ADODB.Recordset
  Dim rstCol As ADODB.Recordset
    
  Set cnn = CurrentProject.Connection
  Set rstTbl = cnn.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "Table"))
  ' List tables.
  With rstTbl
    Do While Not .EOF = True
      Debug.Print .Fields(2).Value
      Set rstCol = cnn.OpenSchema(adSchemaColumns, Array(Empty, Empty, CStr(.Fields(2).Value)))
      ' List fields of table.
      With rstCol
        Do While Not .EOF = True
          Debug.Print vbTab & .Fields(3).Value
          .MoveNext
        Loop
        .Close
      End With
      .MoveNext
    Loop
    .Close
  End With
  
  If rstCol.State = adStateOpen Then
    rstCol.Close
  End If
  If rstTbl.State = adStateOpen Then
    rstTbl.Close
  End If
  If cnn.State = adStateOpen Then
    cnn.Close
  End If
  Set rstCol = Nothing
  Set rstTbl = Nothing
  Set cnn = Nothing
    
End Sub

/gustav

>>> harkinsss at bellsouth.net 13-03-2006 02:26 >>>
  Set rst = CurrentProject.Connection.OpenSchema(adSchemaColumns,
Array(Empty, Empty, Empty, "Shippers"))
 
I can't remember the exact syntax for filtering a schema recordset to a
specific table -- anyone remember which array element I'm supposed to use.
I've moved the table name around, but I either get an error or an empty
recordset. 
 
Susan H. 




More information about the AccessD mailing list