Retrieving Table List

Retrieving Table List

How can I get the tables within an Access2.0database to show in a list box? The user willspecify a database in a text box and I want themto be able to choose which table they want to workwith. Also, once I get the table, how can I havethe fields of that table show up in another listbox? I have tried using the List Fields Method tono avail.

You can loop through the TableDefs collection, which is a property of the Database object. Those are all the tables in the currently active database. You can add them into the list box with the AddItem method. Here’s an example:

Dim db as DatabaseDim td as TableDefSet db = OpenDatabase(“Filename”)ListBox.ClearFor Each td In db.TableDefs   ListBox.AddItem td.Name   db.TableDefs.MoveNextLoop


Share the Post: