Results 1 to 12 of 12
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Finding unused Queries

    I would like to check my db for unused queries. I made a lot of queries and I know some are just hanging out there being of no use at all.



    I found online a VBA program that might help:

    Code:
    Public Sub CheckQueries(ByVal str as String)
    
    Dim qu As QueryDef
    
    For Each qu In CurrentDb.QueryDefs
          If InStr(qu.SQL, str) > 0 Then
              Debug.Print qu.Name
          End If
    Next
    
    End Sub
    The question is will this code work. If it will work, then where do I place it in the already existing db?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    dont.
    an extra query lying around wont hurt anything and doesnt take up any room.
    deleting a query that IS needed , does hurt.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    The question is will this code work
    yes it will work. The bigger question is 'will it work the way I want'. And I don't know the answer to that because I don't know what you want it to do. 'I would like to check my db for unused queries' is not a sufficiently detailed requirement

    where do I place it in the already existing db
    in a new or existing module

    You can use the object dependencies function on the developer tab to find out where the query is used

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I've read on MSDN that Access doesn't have a developer tab, but maybe that's outdated info. Can't find it in 2007 and have never seen it, but don't know why you'd need one either. However, you're using 2010, so I'm curious as to what's on that tab that you can use that I can't?

  5. #5
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I will look and get back to you. Please be more specific.

    Respectfully,

    Lou Reed

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I've read on MSDN that Access doesn't have a developer tab,
    my bad. typing from memory. In access it is called Database Tools

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Lou,

    How do you know this? Do you know, or do you suspect?

    I know some are just hanging out there being of no use at all.

  8. #8
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Lou -

    That code will not do what you want, and I dont think that is what is is intended to do. I looks like it is supposed to find queries that are used as part of other queries, but it won't do that reliably either. Don't bother with it.

    Even if that code was written properly, it will not find queries that are used or referenced in VBA code.

  9. #9
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You might look at the "RubberDuck" add in at http://rubberduckvba.com
    Click on "Learn More" under Code Inspections

    I just installed it 2 days ago and haven't had a lot of time to do much testing, but it does look promising.
    Project is being hosted on github.com.

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Steve,
    Did you learn about rubber duck through the Steve Bishop videos?
    I'm interested in your review/usage.

  11. #11
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @orange, Actually, it was mentioned in an article in databasejournal.com. I was looking for articles on how to connect Access forms/reports using views/SPs.....
    Haven't had time to try it out yet.

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Finding specific values in queries
    By FLindh in forum Queries
    Replies: 1
    Last Post: 07-11-2016, 04:12 AM
  2. Finding Queries that contain Form Criteria
    By mrmmickle1 in forum Programming
    Replies: 3
    Last Post: 01-21-2016, 05:05 PM
  3. Deleting unused subs
    By snipe in forum Programming
    Replies: 2
    Last Post: 12-20-2013, 01:57 PM
  4. Queries for determining unused amounts of assets/cash
    By Long Tom Coffin in forum Queries
    Replies: 8
    Last Post: 07-05-2012, 01:38 PM
  5. Replies: 1
    Last Post: 11-22-2010, 11:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums