Create list box with table names

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

Guest

I have a form (frmTbl) with a list box (lstTbls) and want to propogate the
list box with a list of tables in the current database (they are linked to
the backend table). I would appreciate any help on how to code this.

Thank you.
 
I have a form (frmTbl) with a list box (lstTbls) and want to propogate the
list box with a list of tables in the current database (they are linked to
the backend table). I would appreciate any help on how to code this.

Thank you.

Set the List Box RowSourceType property to Value List.
Code the Form's Load event:

Dim dbs As Database, tdf As TableDef, strList As String
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Left(tdf.Name, 4) <> "MSYS" Then
strList = strList & tdf.Name & ","
End If
Next tdf
Me.[lstTbls] RowSource = strList
Set dbs = Nothing
 
try this query for a simple way:

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Name) Not Like "msys" & "*") AND
((MSysObjects.Type)=1));

BTW, it excludes system tables (on the assumption you really don't want to
see them..)
 
Back
Top