Solved

HIDE A TABLE

Posted on 2002-03-25
10
486 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
 
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HasData 9 36
MS Access 2016 Debugging 7 42
Error in Rs.MoveNext & Duplication of Record 14 25
MS Access 03, TransferText, decimal places 8 43
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

910 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

21 Experts available now in Live!

Get 1:1 Help Now