Need to programmatically Hide an ACCESS table with Visual Basic.

B

bob

These are from my notes. Not my own. Source unknown:

Programmatically hiding tables safely (Access 2000/2002)

Some time ago we ran a tip that discussed hiding objects in the
Database window. As you may recall, you can hide an object by
right-clicking on it, choosing Properties from the shortcut menu
and then selecting the Hidden check box. One reader wrote in
with concerns regarding concerns relating to a bug that can cause
hidden tables to be deleted. First, be reassured that there's
nothing to fear--the user interface technique we discussed is
totally safe. The behavior that could cause tables to get
deleted only comes into play when a table is hidden
programmatically using DAO.

Although you shouldn't use DAO to programmatically hide tables,
there is a safe way to programmatically hide them from view in
the Database window--if you have Access 2000 or above. To do so,
use the SetHiddenAttribute method. This method applies to the
Application object and uses the syntax:

SetHiddenAttribute ObjectType, ObjectName, fHidden

Essentially, is the programmatic equivalent to the Hidden check
box available through the user interface. The ObjectType
argument accepts one of the standard AcObjectType constants (like
acForm or acTable) and is used to indicate the type of object
with which you're working. The ObjectName argument is simply the
name of the object and fHidden accepts True or False to determine
whether the object is hidden.

To illustrate, let's say that you have a database containing a
table named tblOrders. You can use the following two procedures
to programmatically change whether the table is visible in the
Database window.


Sub HideTable()
Application.SetHiddenAttribute acTable, "tblOrders", True
End Sub

Sub ShowTable()
Application.SetHiddenAttribute acTable, "tblOrders", False
End Sub

If you want to check whether a database object is hidden, you
can do so with the GetHiddenAttribute method. For example, use
the following procedure to display the tblOrders table's visible
status in the Immediate window:

Sub TableHiddenStatus()
Debug.Print Application.GetHiddenAttribute(acTable, "tblOrders")
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top