Results 1 to 4 of 4
  1. #1
    JohnLouisWood is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    52

    First and Last seem to be working backwards


    I am working with a couple of queries. When I try to find the first value, I get the last value, and vice-versa.
    This is not just happening with the queries that I am showing, but seems to be happening 'always' with the other sets/copies of queries that I am working with.
    Here is the SQL for query v4:
    SELECT Res_15cws_v3_Query.Total15ws, First(Res_15cws_v3_Query.Max_cws) AS F_Max_cws,
    Count([Res_15cws_v2_Query]![CountY]) AS Cnt_Max,
    First(Val(Res_15cws_v2_Query.FallY)) AS Fir_Fall,
    First(Res_15cws_v2_Query.FallN) AS Fir_End,
    Last(Res_15cws_v2_Query.FallY) AS Lst_Fall, Last(Res_15cws_v2_Query.FallN) AS Sec_EndClick image for larger version. 

Name:	Screenshot (35).jpg 
Views:	11 
Size:	153.6 KB 
ID:	50017
    FROM Res_15cws_v3_Query, Res_15cws_v2_Query
    WHERE ((([Res_15cws_v2_Query]![CountY])=[Res_15cws_v3_Query]![Max_cws]))
    GROUP BY Res_15cws_v3_Query.Total15ws;

  2. #2
    JohnLouisWood is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    52
    Guci (Vlad) suggested using MIN and MAX instead of First and Last. It seems to solve this problem.

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    First and Last are (IMHO) virtually useless function is Access SQL.
    They really don't do what people expect them to do, and can easily return completely arbitrary results. I'd remove them!
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    First and last depend on the order of the data?
    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

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

Similar Threads

  1. Display Top X, and move X backwards from there
    By SamL in forum Programming
    Replies: 7
    Last Post: 11-15-2021, 01:00 PM
  2. Replies: 7
    Last Post: 08-26-2016, 07:45 AM
  3. Replies: 6
    Last Post: 09-22-2015, 12:14 PM
  4. I think I put the keys backwards in my database design.
    By Melaniecarr23 in forum Database Design
    Replies: 1
    Last Post: 03-11-2014, 09:15 PM
  5. Forms Populating Backwards
    By kbrown in forum Forms
    Replies: 0
    Last Post: 06-21-2011, 09:47 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