Solved

HIDE A TABLE

Posted on 2002-03-25
10
490 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server views 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 Access…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

770 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