Results 1 to 4 of 4
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    237

    Latest address of a person

    Hi,


    I have addresses for different persons (One to many) and I keep track of these addresses and add the new address when someone changes his address. I am able to print a report / show all addresses for any person.
    Is it possible to have a query that shows the latest address of a person only based on a field name DateFrom. This field (DateFrom) shows the date that person changed his address and moved to a new place.

    Thanks
    Khalil

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Try:

    SELECT Addresses.* FROM Addresses WHERE DateFrom = (SELECT Max(DateFrom) FROM Addresses AS Dupe WHERE Dupe.PersonID = Addresses.PersonID);

    or

    SELECT Addresses.* FROM Addresses WHERE DateFROM = DMax("DateFrom", "Addresses", "PersonID=" & [PersonID])
    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.

  3. #3
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    237
    Hi,
    Done
    Thank you

  4. #4
    Join Date
    Apr 2017
    Posts
    1,673
    Or something like
    SELECT TOP 1 addr.* FROM Addresses addr WHERE addr.PersonID = PersonIdValue ORDER BY DateFrom DESC

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

Similar Threads

  1. Replies: 4
    Last Post: 05-12-2021, 06:20 AM
  2. Replies: 3
    Last Post: 03-16-2017, 02:35 PM
  3. Replies: 19
    Last Post: 01-24-2016, 07:48 PM
  4. Replies: 3
    Last Post: 06-26-2014, 10:18 PM
  5. Replies: 2
    Last Post: 08-22-2013, 12:02 AM

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