Table Attribute: Hidden = True

  • Thread starter Thread starter Kan D.
  • Start date Start date
K

Kan D.

How do I programmatically assign a "True" value to a particular table's
"Hidden" attribute?

Kan
 
Klatuu said:
CurrentDb.TableDefs("MyTableName").Attributes = dbHiddenObject

NO! Don't do it that way. Unless they've fixed this bug in recent
versions, adding dbHiddenObject to any table's Attributes will cause the
table to be deleted during the next compact operation.

Use

Application.SetHiddenAttribute acTable, "TableName", True

instead.

(Incidentally, even if using dbHiddenObject were safe, you wouldn't want
to just set the Attributes to that one attribute -- you'd be smashing
any other attribute bits the table might have set. You would need to OR
the attribute value instead.)
 
Thanks, Dirk. I wasn't aware of that bug.

Dirk Goldgar said:
NO! Don't do it that way. Unless they've fixed this bug in recent
versions, adding dbHiddenObject to any table's Attributes will cause the
table to be deleted during the next compact operation.

Use

Application.SetHiddenAttribute acTable, "TableName", True

instead.

(Incidentally, even if using dbHiddenObject were safe, you wouldn't want
to just set the Attributes to that one attribute -- you'd be smashing
any other attribute bits the table might have set. You would need to OR
the attribute value instead.)

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Klatuu said:
Thanks, Dirk. I wasn't aware of that bug.

Scary, ain't it? You do what looks perfectly reasonable -- and the help
file even says, "dbHiddenObject: The table is a hidden table provided
by the Microsoft Jet database engine. You can set this constant on an
appended TableDef object." -- and run the risk of losing your table
completely. Not good.
 
Klatuu said:
Thanks, Dirk. I wasn't aware of that bug.

Hmm. I've done a bit of follow-up research, and what I'm reading
suggests that Jet 4.0 has fixed this bug. So if you're using Access
2000 or later (and not working with an unconverted Access 97 database),
you should be okay. I still don't trust it, though.
 
Are you suggesting there are inaccuracies and vague information in Microsoft
Help files and KB documents?
What kind of heretic are you :)
I know there is some out of date information, but isn't that just Old
Testament stuff?
 
Kan said:
How do I programmatically assign a "True" value to a particular table's
"Hidden" attribute?


Make sure you test that using a copy of your table. This
attribute has been used to mark a table for deletion during
the next Compact operation. The Hidden property you can set
from the db window is not the same as the Hidden attribute
in a tabledef object.

One workaround is to name the table starting with USYS to
mark it as a system object that can be hidden through the
Tools Options menu.
 
use this

Public Sub prcHide()
Dim db As DAO.Database
Dim tds As DAO.TableDefs
Dim td As DAO.TableDef
Dim restd As DAO.Recordset
On Error Resume Next
Set db = CurrentDb()
Set tds = db.TableDefs
For Each td In tds
'if td.Attributes
Application.SetHiddenAttribute acTable, td.Name, True
Next

End Sub




CurrentDb.TableDefs("MyTableName").Attributes = dbHiddenObject

"Kan D." wrote:

> How do I programmatically assign a "True" value to a particular table's
> "Hidden" attribute?
>
> Kan
>
>
>
 
Back
Top