473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Help hiding table in VB

365 100+
Hello to all you forum goers,

I have another one of my random (to most people) questions

i want a vb routine to hide and unhide tables in access (obviously)
i was thinking of something like this
Expand|Select|Wrap|Line Numbers
  1. Dim tdf As DAO.TableDef
  2.     For Each tdf In CurrentDb.TableDefs
  3.         tdf.Attributes = dbHiddenObject
  4.     next
but i want to exclude the system tables etc,
and im not sure what the attribude code is for a normal table to unhide it,

im sure this is an easy one for the experts

thanks in advance

Dan
Nov 4 '09 #1

✓ answered by ADezii

I've created a simple Public Sub-Routine for you that will Hide/Unhide any Table. Simply pass to the Routine the Table Name (String), and a Boolean Value (True/False) indicating whether or not to Hide the Table or Unhide it.
  1. Sub-Routine definition:
    Expand|Select|Wrap|Line Numbers
    1. Public Sub HideTable(strTableName As String, blnHide As Boolean)
    2.   Application.SetHiddenAttribute acTable, strTableName, blnHide
    3. End Sub
  2. Sample usage:
    Expand|Select|Wrap|Line Numbers
    1. 'To Hide Table1
    2. Call HideTable("Table1", True)
    3.  
    4. 'To Unhide Table1
    5. Call HideTable("Table1", False)
  3. To Hide/Unhide ALL Tables excluding System and Temporary Tables:
    Expand|Select|Wrap|Line Numbers
    1. Dim tdf As DAO.TableDef
    2.  
    3. For Each tdf In CurrentDb.TableDefs
    4.   If Mid$(tdf.Name, 2, 3) <> "Sys" And Left$(tdf.Name, 1) <> "~" Then
    5.     Call HideTable(tdf.Name, True)      'Hide
    6.     'Call HideTable(tdf.Name, False)    'Unhide
    7.   End If
    8. Next
  4. Some other useless code:
    Expand|Select|Wrap|Line Numbers
    1. Public Function fIsTableHidden(strTableName As String) As Boolean
    2.   fIsTableHidden = Application.GetHiddenAttribute(acTable, strTableName)
    3. End Function
  5. Useless code usage (is that redundant?):
    Expand|Select|Wrap|Line Numbers
    1. If fIsTableHidden("Table1") Then
    2.   MsgBox "Table1 is Hidden"
    3. Else
    4.   MsgBox "Table1 is NOT Hidden"
    5. End If

4 7267
ADezii
8,834 Expert 8TB
I've created a simple Public Sub-Routine for you that will Hide/Unhide any Table. Simply pass to the Routine the Table Name (String), and a Boolean Value (True/False) indicating whether or not to Hide the Table or Unhide it.
  1. Sub-Routine definition:
    Expand|Select|Wrap|Line Numbers
    1. Public Sub HideTable(strTableName As String, blnHide As Boolean)
    2.   Application.SetHiddenAttribute acTable, strTableName, blnHide
    3. End Sub
  2. Sample usage:
    Expand|Select|Wrap|Line Numbers
    1. 'To Hide Table1
    2. Call HideTable("Table1", True)
    3.  
    4. 'To Unhide Table1
    5. Call HideTable("Table1", False)
  3. To Hide/Unhide ALL Tables excluding System and Temporary Tables:
    Expand|Select|Wrap|Line Numbers
    1. Dim tdf As DAO.TableDef
    2.  
    3. For Each tdf In CurrentDb.TableDefs
    4.   If Mid$(tdf.Name, 2, 3) <> "Sys" And Left$(tdf.Name, 1) <> "~" Then
    5.     Call HideTable(tdf.Name, True)      'Hide
    6.     'Call HideTable(tdf.Name, False)    'Unhide
    7.   End If
    8. Next
  4. Some other useless code:
    Expand|Select|Wrap|Line Numbers
    1. Public Function fIsTableHidden(strTableName As String) As Boolean
    2.   fIsTableHidden = Application.GetHiddenAttribute(acTable, strTableName)
    3. End Function
  5. Useless code usage (is that redundant?):
    Expand|Select|Wrap|Line Numbers
    1. If fIsTableHidden("Table1") Then
    2.   MsgBox "Table1 is Hidden"
    3. Else
    4.   MsgBox "Table1 is NOT Hidden"
    5. End If
Nov 4 '09 #2
Dan2kx
365 100+
i modified the code slightly and get an error, this is what i modified it to
Nov 4 '09 #3
Dan2kx
365 100+
Expand|Select|Wrap|Line Numbers
  1. Function SecureTable(qLock As Boolean)
  2. Dim tdf As DAO.TableDef
  3.     For Each tdf In CurrentDb.TableDefs
  4.         If Mid$(tdf.Name, 2, 3) <> "Sys" And Left$(tdf.Name, 1) <> "~" Then
  5.             Application.SetHiddenAttribute acTable, tdf, qLock
  6.         End If
  7.     Next
  8. End Function
error is type mismatch highlighting "SetHiddenAttribute"
have i gone too far (in my ADezii MOD)?
Nov 4 '09 #4
Dan2kx
365 100+
Ahh think i got it, needed to use tdf.name on line #5

Thanks for the help
Nov 4 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: F. Da Costa | last post by:
Following is a snippet of html in which I hide a whole table and try to hide a single row. Here is my question (plz don't chew my head off if its css related instead): Why does the divTable...
5
by: mt | last post by:
In a nutshell, I'd like to have a list of items, each of which fills out a small table which displays some info about a particular item(the items being a trouble ticket for a tech support ASP-built...
1
by: luvdairish | last post by:
Can someone please look at my code and see why tables are not hiding properly? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Untitled Document</TITLE> <META...
6
by: luvdairish | last post by:
I tried posting a few times, but it hasn't shown up. Hope this one works. Problem: Having trouble hiding tables when page is loaded. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
5
by: Ben | last post by:
I have a form for data entry which is in a table. I have a select box to enter a customer name, which takes it's options from the customer database. I have a button to add a new customer. What I...
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
1
by: Doug | last post by:
Looking for opinions/suggestions: Suppose I have a "region" of an aspx page I want to hide or show based on whatever runtime conditions. Additionally, the entire region is defined by an HTML...
10
by: 60325 | last post by:
This is the page where I collect the data in drop-down boxes with values of 1-10 and send it to a submitted page to do calculations. Example: Employee1 TeamScore(1-10) Employee2 ...
2
by: Severus Snape | last post by:
I can display and hide 1 object at a time, but haven't seen it done on multiple objects simultaneously. I have four (or more) tables on a page that start off hidden, and I want to toggle their...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.