Results 1 to 5 of 5
  1. #1
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,046

    Need efficent method for finding "query within query"

    Experts:



    I need some general assistance with Access database management.

    Background - General:

    - Attached is a sample database which contains a few sample tables, 4 queries, 4 forms.
    - My actual database, however, is much larger and includes roughly 100+ queries and about 20 forms
    - These 100+ queries and ~20 forms have been developed over the last couple of months.
    - At this time, I am going through a "cleanup" process. That is, I'm trying to which queries are a) required vs. b) not requred by any forms/reports/VBA, etc.

    Background on Forms/Reports:
    - As a general rule, I never utilize the query name in any of my forms and/or reports.
    - That is, if a query is the source for a form or report, I always utilize the actual SQL as my rowsource. In my view, this reduces the number of query objects in my database.
    - However, in both form and reports, I **do** utlize the query name (e.g., Query1) inside my VBA.

    Now, before I delete any **potentially** unnecesasary query, I utilize a "Find" across "Current Project" (see attached "FindQueryinVBA.jpg"). Naturally, if the query is found, it won't be a candidate for deletion.
    Given that I only have about 20 forms, conducting a "Find" is relatively straight-foward as does NOT take too much time.

    However, some of my queries are part of other queries (i.e., Query1 may serve as an input to Query2). More specifally, in the attached sample database, "Q_Step4" is part of my query "Q_Step3". Naturally, if I had deleted Q_Step4, Q_Step3 would no longe work.

    So, while it's easy to determine whether or not a query is used in my Forms' VBA, I haven't figured out a way how to "find a query within a query". Sure, I could open any of the 100 queries and copy the SQL into an ASCII program and the search for it; however, I'm afraid that would take a signficant amount of time and potentially opens me for making errors.

    Thus, my question: Is there an efficient way to search the database and determine which query is utilized in another query so that I won't accidentially delete a required object? If so how?

    EEH
    Attached Thumbnails Attached Thumbnails Q_Step3 references Q_Step4.JPG   FindQueryinVBA.JPG  
    Attached Files Attached Files

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    First, delete nothing - rename to "zz"+the existing name. If you show all objects in the nav pane as I do, zz pretty much guarantees that it drops to the bottom of the list where I ignore it for a time. At some point after testing most/all of the processes, I figure it isn't needed so then it goes. This might be same day or weeks later. If something breaks, it's usually obvious which of the renamed objects is the culprit based on the error message raised, and so the zz gets removed and you're back in business.

    Second, there is the database documenter and with it you can look at all properties or just the data related ones. All properties with your db is likely to generate a 50 page report, so start with the data. You would have to read carefully but this should expose that query1 depends on query2. While this is also possible to see using the dependencies tool, that will not show you that cmbCustomer on form frmCust relies on a query or a lookup in txtName relies on a query field for example. From reading your post I'd say there's no need to reinvent the wheel.
    Last edited by Micron; 02-14-2020 at 03:30 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,046
    Micron - using the "zz" prefix is an excellent idea. I will start there before deleting any queries.

    Thanks for the excellent advice.

    Cheers,
    Tom

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    You're welcome. Glad I could help.
    Try the documenter if you're not familiar with it.

  5. #5
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,046
    Yes, I definitely will check it out.

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

Similar Threads

  1. Using "Make Table" query versus "Select" query
    By Bcanfield83 in forum Database Design
    Replies: 3
    Last Post: 01-04-2019, 05:11 PM
  2. Replies: 3
    Last Post: 06-06-2018, 08:26 PM
  3. Replies: 4
    Last Post: 12-20-2015, 12:16 PM
  4. Replies: 1
    Last Post: 02-05-2015, 05:41 PM
  5. Replies: 4
    Last Post: 01-03-2013, 03:50 PM

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