Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HIDE A TABLE

Posted on 2002-03-25
10
Medium Priority
?
506 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

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…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

916 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