M
Mark VII
Greetings --
The quick question here is "can I get a list of fields in a table without
enumerating the fields collection of the tabledef"? Trying to do this is
blowing up Access.
Here's the long version of the question -- I'm working with a rather complex
database where I have a combo box on a form, populated with name of the
tables in the database. Another combo box lists the fields in the selected
table. The table list combo box's row source is a custom function that
enumerates the tables collection of the database. The field list combo box's
row source is a custom function that enumerates the fields collection of the
selected table.
Everything had been working, then suddenly, any of the code that steps
through either the tables collection or the fields collection of a table
causes Access to "experience an error and need to shut down".
Even this little snippet blows up at the "For Each tdf In cat.Tables"
statement.
Public Function TableLister()
Dim dbs As ADODB.Connection
Dim cat As ADOX.Catalog
Dim tdf As ADOX.Table
Set dbs = CurrentProject.Connection
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = dbs
For Each tdf In cat.Tables
Debug.Print tdf.Name
Next tdf
End Function
I've tried decompiling the database followed by compact and repair, no luck.
I've created a new database and imported the objects from the existing
database, no luck. This logic "used to work", and the modfications I made
most recently don't even touch this code.
Does anyone have any suggestions? I was able to stop enumerating the tables
collection by querying MsysObjects, but I haven't found a way to list the
fields in a table without enumerating the fields collection.
Thanks....
Mark
The quick question here is "can I get a list of fields in a table without
enumerating the fields collection of the tabledef"? Trying to do this is
blowing up Access.
Here's the long version of the question -- I'm working with a rather complex
database where I have a combo box on a form, populated with name of the
tables in the database. Another combo box lists the fields in the selected
table. The table list combo box's row source is a custom function that
enumerates the tables collection of the database. The field list combo box's
row source is a custom function that enumerates the fields collection of the
selected table.
Everything had been working, then suddenly, any of the code that steps
through either the tables collection or the fields collection of a table
causes Access to "experience an error and need to shut down".
Even this little snippet blows up at the "For Each tdf In cat.Tables"
statement.
Public Function TableLister()
Dim dbs As ADODB.Connection
Dim cat As ADOX.Catalog
Dim tdf As ADOX.Table
Set dbs = CurrentProject.Connection
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = dbs
For Each tdf In cat.Tables
Debug.Print tdf.Name
Next tdf
End Function
I've tried decompiling the database followed by compact and repair, no luck.
I've created a new database and imported the objects from the existing
database, no luck. This logic "used to work", and the modfications I made
most recently don't even touch this code.
Does anyone have any suggestions? I was able to stop enumerating the tables
collection by querying MsysObjects, but I haven't found a way to list the
fields in a table without enumerating the fields collection.
Thanks....
Mark