Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting table name of MY TABLES only !

Status
Not open for further replies.

marco02

Programmer
Feb 19, 2002
35
US
Hi guys, is there a smarter way to retrieve the names of MY tables in my dtb with SKIPPING all those hidden and MSsystem tables ?

This usually works but it's dumb, you will agree ...

Set Dtb = CurrentDb
For Each Tdf In Dtb.TableDefs
If Left(Tdf.Name, 4) <> &quot;MSys&quot; And _
Left(Tdf.Name, 4) <> &quot;~TMP&quot; Then

MsgBox Tdf.Name

End If
Next Tdf

thanks
 
Its not dumb, but you have used the easier method. If you check the properties (attributes) of the tables using &quot;dbSystemObject&quot; or &quot;dbHiddenObject&quot; you can determine if you want to see it or not. Something like this for example :-

#########################################################
Dim dbs As Database, tdf As TableDef

Set dbs = CurrentDb

For Each tdf In dbs.TableDefs
If (tdf.Attributes And dbSystemObject) Then
MsgBox tdf.Name & &quot; : System Table&quot;
Else
MsgBox tdf.Name & &quot; : Not A System Table&quot;
End If
Next tdf

Set dbs = Nothing
#########################################################

The main &quot;If&quot; statement uses a bitwise comparison to determine if an attribute is currently set or not.

Hope this helps,
TopJack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top