Solved

HIDE A TABLE

Posted on 2002-03-25
10
483 Views
Last Modified: 2008-08-04
HOW CAN I HIDE AN ACCESS DATABASE TABLE THROUGH PROGRAM?
0
Comment
Question by:MAHA
10 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
Comment Utility
I don't think you can, from code.  What exactly are you trying to accomplish by HIDING a table?
0
 
LVL 11

Expert Comment

by:joekendall
Comment Utility
You can hide a table through code. Below is a sub I wrote to hide a table. Make sure you read the Note in the comments.

Public Sub HideTables()

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'If you set the Attributes property of a TableDef object
'to dbHiddenObject, Microsoft Access hides the TableDef
'object. The TableDef object exists in the TableDefs
'collection, but you cannot see it in the Database window,
'even if you have selected the Show Hidden Objects option
'in the Options dialog, which is available by clicking on
'the Tools menu. To create a TableDef object that can be
'either hidden or visible, set the Attributes property to
'dbSystemObject. You can then make the TableDef object
'visible in the Database window by selecting Show System
'Objects in the Options dialog.
'
'Note: If you Repair and Compact, then you will lose
'any Tables Hidden programmatically.
'
'Joe Kendall 2/19/2001
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
   
    Const SHOWTABLE = 0
   
    Dim tdf As TableDef
   
    For Each tdf In CurrentDb.TableDefs
        If tdf.Name Like "MSys*" Or tdf.Name Like "~*" Then
        Else
            'Just change dbHiddenObject to SHOWTABLE if you would like to see it again.
            tdf.Attributes = dbHiddenObject
        End If
    Next tdf
   
    Set tdf = Nothing
   
End Sub

Thanks!

Joe
0
 

Expert Comment

by:muzori
Comment Utility
Joe,
sorry can make more clear where I can put this code.
secondly If i hide how can i make inhide again.



thanks
0
 
LVL 11

Expert Comment

by:joekendall
Comment Utility
You put the code in a code module. As for unhiding the table, it is documented in the code.

Thanks!

Joe
0
 
LVL 4

Expert Comment

by:nmilmine
Comment Utility
Hi MAHA

This is code I use to both hide and unhide

Sub DisplayTables()
 
 Dim tdf As TableDef, i As Integer
 
 For Each tdf In CurrentDb.TableDefs
      If tdf.Name Like "msys*" Then
      Else
          tdf.Attributes = i
      End If
  Next tdf
 
 Set tdf = Nothing
 
End Sub

Sub HideTables()
   
   Dim tdf As TableDef
   
   For Each tdf In CurrentDb.TableDefs
       If tdf.Name Like "msys*" Then
       Else
           tdf.Attributes = dbHiddenObject
       End If
   Next tdf
   
   Set tdf = Nothing
   
End Sub

I use a button on a form to run each of the codes

Private Sub Hide_All_Tables_Click()

    HideTables

End Sub

Private Sub Display_All_Tables_Click()

    DisplayTables

End Sub

Regards
Neil
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Expert Comment

by:cquinn
Comment Utility
You can also name the table with a Usys prefix eg UsysTable and it will be hidden by default
0
 
LVL 5

Expert Comment

by:gwgaw
Comment Utility
'Note: If you Repair and Compact, then you will lose
'any Tables Hidden programmatically.


I always use the dbHiddenObject attribute and have never had a problem with
not being able to access the table after compacting and repairing the database.
0
 
LVL 11

Expert Comment

by:joekendall
Comment Utility
To take care of the Repair and Compact problem, you can loop through the tables and unhide them. Then, you can repair and compact. Finally, you can hide them again. It requires a little work, but you can handle it efficiently.

Thanks!

Joe
0
 
LVL 54

Expert Comment

by:nico5038
Comment Utility
for MAHA

No comment has been added for the last two months.
So it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
Comment Utility
Per recommendation, points NOT refunded and question closed.

Netminder
CS Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now