Results 1 to 7 of 7
  1. #1
    tdob12 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    4

    If update query has multiple record options to choose from, which one will it select?


    I have a database with two tables.

    On an update query, Table 1 pulls in information from Table 2 with a link on "Ticket #" column.

    However, Table 2 may contain multiple records with the same ticket number.

    Table 2 is sorted by a timestamp column (descending), so that the newest records are on top.

    From what record will the update query pull from Table 2 into Table 1, the newest or the oldest?

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Not sure but why not use a grouped subquery to pick the newest values if that's what you always want

  3. #3
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    Do you have to update Table1 with Table2 data? Why not just link in a Select query and display the data from the query instead of from Table1?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Maybe random. Not sure the sort order will have any bearing on which value is pulled. I have never explored this and always designed to avoid this situation. But try it and find out.

    However, why do this to begin with? Saving calculated data is usually unnecessary and pulling the Max date is a calculation. This maximum date value can always be pulled with a query. No reason to save it into another table.


    Advise no spaces or punctuation/special characters (underscore only exception) in naming.
    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.

  5. #5
    tdob12 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    4
    Click image for larger version. 

Name:	query1.PNG 
Views:	14 
Size:	5.6 KB 
ID:	28894 Ok here is a select query off of Table 2. Ticket Number and Date Added should be all set. For "Total" under "Owner", what should I put so that the Owner comes from the same record as the latest (max) Date Added

    Or should I be going about this a different way?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    That query cannot be relied on to return the owner associated with max date. If you want the max date and associated owner for each ticket, a TOP N nested subquery is one approach. Review http://allenbrowne.com/subquery-01.html#TopN
    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.

  7. #7
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    Can you post some raw data from Table 1 and Table 2 so we can see how the data is stored.

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

Similar Threads

  1. Replies: 9
    Last Post: 01-31-2017, 05:13 PM
  2. Update Query Options/Direction
    By bigroo in forum Queries
    Replies: 4
    Last Post: 05-05-2014, 06:52 PM
  3. Multiple options for query criteria
    By graccess in forum Queries
    Replies: 2
    Last Post: 03-17-2014, 05:01 PM
  4. Replies: 1
    Last Post: 08-30-2011, 07:35 AM
  5. Choose a record from a query?
    By Kevo in forum Forms
    Replies: 12
    Last Post: 07-15-2011, 09:47 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