dbHidden Attribute

J

Jim Pockmire

What code can I use to change hide an existing table (dbhidden attribute),
and what attribute reverses dbHidden to make the table visible again?
 
D

Dirk Goldgar

Jim Pockmire said:
What code can I use to change hide an existing table (dbhidden
attribute), and what attribute reverses dbHidden to make the table
visible again?

In Access 2000 (I believe) or later, do it like this:

' Hide the table
Application.SetHiddenAttribute acTable, "YourTableName", True

' Show the table
Application.SetHiddenAttribute acTable, "YourTableName", False

There was a bug in Access 97 -- maybe fixed, maybe not -- that would
cause a a table to be deleted the next time you compacted the database,
if you hid it by setting the dbHidden attribute of the DAO TableDef
object.
 
P

Paul Overway

The bug you're referring to applied when setting the Attribute property for
a tabledef to dbHiddenObject (1) in Access 97. The method you describe is a
little different in that the tabledef is still visible if you enable the
option to see hidden objects. Setting the Attribute property for the
tabledef to dbHiddenObject makes the table really invisible in the UI...you
can only see it programmatically. You have to change views in the UI to see
the table disappear, but it does.

The bug *does* appear to be fixed...if you add 1 to Attribute, the table is
hidden and is still there even after compacting. I had thought to use this
functionality once upon a time...hmmm.
 
D

david epsom dot com dot au

Well I wouldn't call it a bug -except possibly a bug in the naming
convention. dao.dbHiddenObject was the property for internal objects
that were not user objects. Unfortunately, VB programmers kept on seeing
that property name and equating it with the Access Application property
of hidden. Unfortunate because if you marked an object as an internal
Jet object, Jet felt free to delete it.

Sometime with Jet 4, MS apparently disconnected the property from it's
original meaning.

(david)
 
J

Jim Pockmire

I tried the following sample code to hide an existing table, but something
is not correct.

Function HideTable(acTable As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
Set tdf = db.TableDefs(acTable)
tdf.Attributes = dbHiddenOdbect
End Function
 
P

Paul Overway

You need to add it/and it to whatever the existing attribute is.

tdf.Attribute = tdf.Attribute And dbHiddenObject
 
Top