Tables and List Boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was wondering if there was a way of displaying a listing of the tables in a database in a list box.
 
=?Utf-8?B?YW5ub255bW91cw==?= said:
I was wondering if there was a way of displaying a listing of the tables in a
database in a list box.

There are 3 different ways of doing this.

Firstly, you can query the MSysObjects table, which is a system table, to
return all tables.

Secondly, you can use the database's TableDefs collection to build up the
RowSource for the list box.

Thirdly, you can use a user-defined function, again using the TablDefs
collection.

For code examples of all three methods, together with an Access 97 sample
database, have a look at http://www.applecore99.com/frm/frm029.asp.
 
-----Original Message-----
I was wondering if there was a way of displaying a
listing of the tables in a database in a list box.

Hi, use online help to lookup AllTables collection and
rowsource for listboxes.

Use the following as an example.

Dim obj As AccessObject
dim strList as string
For Each obj In currentdb.AllTables
strList=strList & chr(34) & obj.name & chr(34)
& ";"
Next obj

' remove extra semi-colon
if len(strList)>0 then
strList=left(strList,len(strList)-1)
end if

lstTable.rowsource=strList

remember to set lstTable.rowsourcetype to value list

Luck
Jonathan
 
Back
Top