Results 1 to 2 of 2
  1. #1
    cherold is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Posts
    82

    can i do an update query that replaces the oldest dated record with a new one?


    I'm trying to create a "most recently opened" record list. So I'd like to just replace the oldest record in that table with the newest one. So:


    Code:
    UPDATE [recently opened] SET id = 1, date = Now() WHERE date = (OLDEST DATE IN TABLE)
    Is there a way to do this?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    make Q1 to get the oldest record,
    select [ClientID] from table where Min([dateFld))

    then the update query, Q2, that uses Q1 in the IN statement of the ID:
    UPDATE TABLE SET TABLE.DateEarned = Date() WHERE (((TABLE.ClientID) In (SELECT [ClientID] FROM q1)));

    note: this is simliar to the method used in FIND DUPLICATES query. Use the wizard to build a Find dupe query and then look at the sql.

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

Similar Threads

  1. Find the oldest date using a query
    By siema24 in forum Queries
    Replies: 4
    Last Post: 04-19-2017, 09:30 AM
  2. Most Recently Dated Record
    By sc6678 in forum Access
    Replies: 2
    Last Post: 12-20-2016, 04:07 PM
  3. Replies: 1
    Last Post: 08-25-2016, 02:10 AM
  4. Replies: 5
    Last Post: 08-16-2016, 07:15 AM
  5. Displaying Oldest and Newest Date in Query
    By spyldbrat in forum Access
    Replies: 2
    Last Post: 07-28-2015, 12:56 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