Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hide all tables (Access 2000)

    I want to create a function that hides all the tables in the database. Since the number of tables
    will vary,i am looking for an global code that hies all available table.Is that possible?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide all tables (Access 2000)

    You can use this procedure:

    Public Sub HideTables(f As Boolean)
    Dim tbl As AccessObject
    For Each tbl In CurrentData.AllTables
    If Not Left(tbl.Name, 4) = "MSys" Then
    Application.SetHiddenAttribute acTable, tbl.Name, f
    End If
    Next tbl
    Set tbl = Nothing
    End Sub

    To hide tables, use

    HideTables True

    and to unhide them, use

    HideTables False

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide all tables (Access 2000)

    Thank you for your reply.When i used the code in a function i got the message
    expected varianle or procedure not a module.
    What did i get wrong?


    Public Function HideTables(f As Boolean)
    'To hide tables, use HideTables True
    'and to unhide them, use HideTables False
    Dim tbl As AccessObject
    For Each tbl In CurrentData.AllTables
    If Not Left(tbl.Name, 4) = "MSys" Then
    Application.SetHiddenAttribute acTable, tbl.Name, f
    End If
    Next tbl
    Set tbl = Nothing
    End Function

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide all tables (Access 2000)

    You probably gave the module the same name as the function (HideTables). This confuses VBA. You should give the module another name.

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide all tables (Access 2000)

    This is exactly what i have done.Thank you

  6. #6
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide all tables (Access 2000)

    it is very interesting, when i put HideTables True
    in the OnOpen event of a form, the tables are not hidden,but when i put it in the OnClick event of a control, they get hidde.Why is it so?

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide all tables (Access 2000)

    I'm sorry, I can't explain that. It should work regardless of the way you call it.

  8. #8
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Hide all tables (Access 2000)

    Just so that other people reading this thread don't make some wrong assumptions, the preferred method of doing this sort of thing is to hide the database window. In general, for serious applications, the user should never be working at the table level - there are too many things users can do either inadvertently or intentionally to break an application, and you'll end up with all sorts of support issues. Also note that all a user has to do to see hidden tables is to turn on the option to show hidden tables.
    Wendell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •