Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,951
    Thanks
    2
    Thanked 1 Time in 1 Post

    Hide Queries (Access 2002)

    Hi

    I have inherited a database with over a hundred queries, most of which relate to 2004, is it possible to hide them in multiples instead of 1 at a time?

    Many thanks

    Braddy
    If you are a fool at forty, you will always be a fool

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

    Re: Hide Queries (Access 2002)

    It shouldn't really matter, since the end user shouldn't see the database window, or work with queries directly.

    Access has no built-in way to hide multiple objects at once, but you could run VBA code to do so. If you want to hide all queries whose name contains 2004, you can use

    Sub HideQueries()
    Dim obj As AccessObject
    For Each obj In CurrentData.AllQueries
    If InStr(obj.Name, "2004") > 0 Then
    SetHiddenAttribute acQuery, obj.Name, True
    End If
    Next obj
    Set obj = Nothing
    End Sub

    Note that this will also hide a query named (for example) qrySales2003_2004 or qrySalesAfter2004.

    If the names of the queries don't indicate the year consistently, you could create a form with a multi-select list box listing all queries. You could indicate which queries to hide. But that might be more work for you than hiding the queries one by one.

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,951
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Hide Queries (Access 2002)

    Hi Hans

    This is only for my use, and I only want to use the 2005 queries so I have to wade through to find the ones I need.

    Having said that I put your code in module but I can't seem to get it to run.

    Braddy
    If you are a fool at forty, you will always be a fool

  4. #4
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: Hide Queries (Access 2002)

    <P ID="edit" class=small>(Edited by hasse on 15-Jun-05 09:28. )</P>a.s. woops... I see Hans already replied before I could finish my suggestion... and provided a better alternative for my suggestion 1/ below... I leave it here fwiw...

    braddy,
    I hope I understand your question right... This is the best I can come up with...

    1/ Access hides all queries with names starting with usys (unless you've the show all system objects option checked). Can you recognize the 2004 queries by there name? If so, you could use a VBA-procedure to rename this group back and forth to invisibility.

    2/ Does your database contain data from multiple years using a 'year' field in the tables concerned (and not one table per year... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>)? If so, there's an alternateve (long term?) approach: you could convert these queries to parameter queries with year = reference to an unbound text/combobox on a (often main) form. Then, you can reuse one query for no matter what year you/the user enters on the form. And you reduce the number of queries in the database window. To easily recognise this group of queries, you could name them like ..._ParYear.

  5. #5
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,951
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Hide Queries (Access 2002)

    Hi Hans

    Oops Sorry, I realised the the year was entered a 04 and not 2004, a quick adjustment to the code resovled the problem.

    Thanks to all who replied

    Braddy
    If you are a fool at forty, you will always be a fool

Posting Permissions

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