Solved

HIDE A TABLE

Posted on 2002-03-25
10
494 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
ID: 6894645
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
ID: 6894730
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
ID: 6895865
Joe,
sorry can make more clear where I can put this code.
secondly If i hide how can i make inhide again.



thanks
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:joekendall
ID: 6896194
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
ID: 6906137
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
 
LVL 15

Expert Comment

by:cquinn
ID: 6909991
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
ID: 6957423
'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
ID: 6959891
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
ID: 7064314
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
ID: 7080462
Per recommendation, points NOT refunded and question closed.

Netminder
CS Moderator
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

685 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