Results 1 to 7 of 7
  1. #1
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085

    Query of a query with a parameter

    I have a query that calls another query. The subquery has a date parameter. The calling query also needs to have a date parameter and the value will be the same for both parameters. Is there a way to pass the parameter from one query to the other without having to enter it twice?

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    AFAIK, only if you use vba. If you know the parameter value, not too hard. If you only know it when the subquery runs, then likely the value has to be found first by using a lookup function - perhaps DLookup. Or you might first retrieve the value from a recordset based on the subquery. In that case, you likely don't run the subquery a second time.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I would set a Tempvar().
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Is the date on a form? You could just reference that date field in both queries?

  5. #5
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085

    Query of a query with a parameter

    Quote Originally Posted by Bulzie View Post
    Is the date on a form? You could just reference that date field in both queries?
    No it is not.

  6. #6
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    566
    What if he nests the parameter query inside second query and declares the parameter there?

    (Wow, I don't miss this part of Access at all!)

  7. #7
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085

    Query of a query with a parameter

    Discovered something I had a typo in the parameter of the 2nd query The parameter in the second query had a space on the end so the names weren't the same which is why it prompted me twice. Once I realized that and matched the parameter name exactly it now prompts me once which is what I wanted in the first place. Thanks for everyone's input.

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

Similar Threads

  1. Replies: 2
    Last Post: 07-13-2019, 02:45 PM
  2. Replies: 2
    Last Post: 01-26-2017, 08:19 AM
  3. Replies: 1
    Last Post: 07-21-2015, 03:38 PM
  4. Replies: 1
    Last Post: 02-28-2013, 01:20 PM
  5. Replies: 13
    Last Post: 01-10-2012, 09:56 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