Results 1 to 12 of 12
  1. #1
    muhammad is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2021
    Posts
    4

    Question I cannot use a query in a query criteria, it asks me for a parameter instead

    Hello, I have a problem that when I enter a value from another query in a query criteria instead of using the value of the criteria it asks for a parameter, here's a picture: first part of the criteria, second part of the criteria, The value from the original query used in the second one, when I run the query I need to additionally say that it works in a different database but I don't know why it works there but not in this database. Thanks a lot for anyone who helps.

  2. #2
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,580
    Hi
    Can you post a screenshot of the Query Builder windows showing the tables & Relationships?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,027
    Quote Originally Posted by mike60smart View Post
    Hi
    Can you post a screenshot of the Query Builder windows showing the tables & Relationships?
    Can you post pics on your very first post?

    Please post the code of the query within code tags and tell us what parameter the query is asking for.
    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
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,580
    Sorry Forgot about that limitation.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Many prefer not to download files from external site. Should be able to embed images in post, otherwise put them in a zip folder with Windows Compression and attach to your post.
    Post the SQL statement as formatted code.
    You could even go to Advanced post editor and build tables of sample data.

    Or better, provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    muhammad is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2021
    Posts
    4
    Here are the images you've asked for:(It asked for the parameter "Max of time!MaxOfTime")

    Click image for larger version. 

Name:	MSACCESS_aB1NDB4AZX.png 
Views:	13 
Size:	70.5 KB 
ID:	46922 Click image for larger version. 

Name:	MSACCESS_BtGKuDLBbp.png 
Views:	13 
Size:	3.0 KB 
ID:	46923

    The query code:
    Code:
    SELECT tblWorkers.FirstName, tblWorkers.LastName, tblWorkers.TimeFROM (((tblBusses INNER JOIN tblCities ON tblBusses.CityID = tblCities.CityID) INNER JOIN tblHistory ON tblBusses.BusID = tblHistory.BusID) INNER JOIN tblWorkers ON (tblWorkers.WorkerID = tblHistory.WorkerID) AND (tblCities.CityID = tblWorkers.CityID) AND (tblBusses.BusID = tblWorkers.BusID)) INNER JOIN tblStation ON (tblStation.StationID = tblWorkers.StaionID) AND (tblStation.StationID = tblHistory.StationID) AND (tblCities.CityID = tblStation.CityID)
    WHERE (((tblWorkers.Time)=[Max of time]![MaxOfTime]));

  7. #7
    muhammad is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2021
    Posts
    4
    I've replied with the information you asked if you could take a look

  8. #8
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,580
    Hi
    Remove the criteria you currently have in the query.

    Then click the Totals Button on the Ribbon Menu.

    Then set the criteria for the "Time" field to "Max"
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  9. #9
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,580
    I would also suggest that you only need the tblWorkers in the query.

    Delete all none required tables
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  10. #10
    muhammad is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2021
    Posts
    4
    Quote Originally Posted by mike60smart View Post
    Hi
    Remove the criteria you currently have in the query.

    Then click the Totals Button on the Ribbon Menu.

    Then set the criteria for the "Time" field to "Max"
    I know but is there a way to make it work when it uses the value from another query? because I will need the use of other queries in the criteria.

  11. #11
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,580
    We can't see the data in your tables so it would help if you can explain your database process to us.

    From the relationships shown in the query it looks like you are recording details about Workers use of Busses?? Please explain.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,834
    is there a way to make it work when it uses the value from another query?
    IMO, only via subquery (where [Max of time] value is retrieved) OR include the query in the design grid and add that field from that query. Your issue is that the query has no idea where to get the value from - it cannot do some sort of lookup just because you designed it without including the query as one of the table sources.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-20-2018, 10:08 AM
  2. Replies: 1
    Last Post: 11-02-2016, 12:41 PM
  3. Replies: 3
    Last Post: 06-18-2015, 01:57 PM
  4. Replies: 12
    Last Post: 06-25-2013, 12:52 PM

Tags for this Thread

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