Results 1 to 6 of 6
  1. #1
    Behedwin is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    61

    Show latest dates of each record

    Hey

    I have have one table with computers (my companies computers).
    ComputerName
    ComputerSerialNumber
    etc

    Then i have Log table where i add data about what actions i have been taking on the computers
    Repairs, handout, inventory etc.


    I want to display when i last made a log entry on each computer and filter out all that are not the latest date.


    so i get a list of when i last made a log entry on each computer. only show the latest entry in the log table on each computer

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Join your two tables in a query.
    Add the ComputerName & ComputerSerial Number form the one table, and then Date field from your other table.
    Then change it to a Totals Query by clicking on the Totals button (looks like a Sigma).
    Under the Date field, change the value on the Totals row from "Group By" to "Max"

    This should give you what you are looking for.
    If you want additional fields from your Log table, then create a new query between this just created query and your Log table on the Computer ID fields AND the Date field.
    Then you can return any fields from the Log table that you want.

  3. #3
    Behedwin is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    61
    It does not work all the way... i still get some duplicates.

    I have a list with dates, names, serialnumber....
    i did as you say and activated totals and set it to MAX on the date column.

    some duplicates are gone and some are not.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Please post the sql for the query you are using.

  5. #5
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    It does not work all the way... i still get some duplicates.

    I have a list with dates, names, serialnumber....
    i did as you say and activated totals and set it to MAX on the date column.

    some duplicates are gone and some are not.
    That usually happens for one of three reasons:

    1. You chose too many fields in the original Totals query. Remember, ALL the fields in that query that have "Group By" on the totals row are included in the duplicate determination!
    That is why you cannot return all the fields, and need to join the back to the original table if you want other fields that are not being used to determine the de-duplication.

    2. You have not done the match on the last query correctly. Remember, you need to join on multiple fields for this one, both the Company ID and the Date.

    3. You have multiple records in your log table with the same max date for some Company IDs. Maybe repairs and handouts happened on the same day for a Company.

  6. #6
    Behedwin is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    61
    Still not getting the correct return as i want.

    I might be doing something wrong or i dont even need Totals and Max function atall....

    Ill try to explain what im after.

    1. I have one table containing the info about IT equipment, computername, serial number etc.
    2. I have one table containing actions done on IT equipment, repairs, handout, returns etc.

    All this is done in different forms to read, add and remove records in above two forms.

    Now i need to print a list of all units.
    And i want to see in this list when i last had my hands on that unit.
    I also want to see a list of units that i have not had my hands on.
    So i know that "these units i need to look for"


    So maybe im asking the wrong questions here.

    1. How to create a list/query that returns all IT Equipments that have not had a Log entry in the last 3 mounts?
    2. How to create a list/query that returns all IT Equipment that HAVE had a Log entry and only show the "latest" log entry?

    My idea with those lists can easily see what units i need to look for. What units have been seen and when.



    If i create a query now with the table containing the Log entries (date, reason, comment).
    I open the query builder, select ITLog_Table
    I then pick out the date column and the Secondary_key ID that have a relationship from another table (IT_Table containing computer names etc).
    So now i have a query with two columns, date and IT_ID
    I now go to Totals and make the date column MAX.

    This seems to work now when im doing it and typing this (ffs).... so ill just keep going and maybe illl solve this
    I name this query as a SUB query and then go and create a new query where i add the table with computernames etc togheter with the recently created sub query.
    So i now have the dates and the names of the computers.

    This seems to have worked now... but how can i now see what units have not had a log entry and are not even being included in this list.
    I dont wanna miss those units
    Tried to do this by creating a new query where ITLog_Table and IT_Table are in a relationship (3) to show all post from IT_Table and only those from ITLog_Table that are alike. Then use the criteria "is null" to filter out those that do have a log entry already....
    Hope this sound correct to you....


    Hopefully i now have two querys that are correct.
    One that show all items that HAVE been logged and i get a list with the LATEST date.
    One list that show all items that HAVE NOT been logged.


    Then when i need to check if i have some units i have not seen in the last few mounths i can look in the list of NOT BEEN LOGGED items.... these units have not been seen for some time most likely. Eventually this list should always be empty unless i add a new computer.
    And then i check the other list of items that HAVE been logged and i see the latest date... sort the list by date and see what units have not been seen in the last couple of months.


    Im sorry if this post became quite messy...
    took some time to write and test things at the same time and eventually i think i solved things... but i need to error check this so i dont miss any units.

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

Similar Threads

  1. Replies: 2
    Last Post: 10-27-2015, 09:12 AM
  2. Replies: 3
    Last Post: 03-20-2013, 01:31 AM
  3. Query to show latest records
    By Conceptz in forum Queries
    Replies: 3
    Last Post: 05-24-2012, 01:01 PM
  4. Limit query to only show the latest record
    By marcustofeles in forum Queries
    Replies: 12
    Last Post: 10-05-2011, 08:06 AM
  5. Mixed dates - show only complete dates?
    By weeblesue in forum Queries
    Replies: 3
    Last Post: 10-27-2010, 02:15 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