
TableDef.Fields.Count is always zero - why?
I am trying to write a utility function to compare two databases and
I've hit a stumbling block. I get two TableDef objects and would like to
examine TableDef.Fields.Count, but it's always zero. In the Object
Browser, I can examine lots of other properties with no problem. (Yes -
the tables have many fields defined.)
Here's a snippet of code I'm using:
Sub CompareOneTable(tblName As String)
Dim tbl1 As TableDef
Dim tbl2 As TableDef
Debug.Print "********************"
Debug.Print "Comparing table "; tblName
Set tbl1 = dbMaster.TableDefs(tblName)
If tbl1 Is Nothing Then
MsgBox "Unable to retrieve " & tblName & "from Master DB!"
GoTo Exit_CompareOneTable
End If
Set tbl2 = dbCopy.TableDefs(tblName)
If tbl2 Is Nothing Then
MsgBox "Unable to retrieve " & tblName & "from Copy DB"
GoTo Exit_CompareOneTable
End If
Call CompareTableFields(tbl1, tbl2)
Exit_CompareOneTable:
Debug.Print "********************"
Set tbl1 = Nothing
Set tbl2 = Nothing
End Sub
---
I have two Database objects, dbMaster and dbCopy, which contain the
objects I want to compare. I have no trouble enumerating the list of
tables in each. If I break on "Call CompareTableFields)", I can view
tbl1 and tbl2 and verify that Fields.Count is zero. The tables are not
linked. Can anyone help? BTW - I have the Access 97 Developer's
Handbook and the VBA Developer's Handbook - both are excellent - but
they don't seem to offer any help on this one.
Thanks,
Mark
--
Mark R. Rinfret, Portsmouth, RI - http://www.*-*-*.com/
UNIX & Internet Project Manager, Stanley Works, E. Greenwich, RI