Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Yes, this can get complicated.

    All the query I provided can do is return the max date. It cannot also show the date field and note field because this is an aggregate query. Including those fields requires them to be in the GROUP BY clause. The suggested query will have to be used in another query that joins on job ID and date values. Problem is the Format function results in a string not an actual date. Also, there is the time component to deal with, which my suggested query does not.

    qryMaxDates
    SELECT tblClientInfo.[Job Number], Max(Format([NoteDate],"yyyy/mm/dd hh:mm:ss")) AS MaxOfNoteDate
    FROM tblClientInfo LEFT JOIN tblNotes ON tblClientInfo.[Job Number] = tblNotes.ClientID
    GROUP BY tblClientInfo.[Job Number];

    qryNotesAdj
    SELECT tblNotes.NotedID, tblNotes.NoteDate, tblNotes.User, tblNotes.Notes, tblNotes.ClientID, Format([NoteDate],"yyyy/mm/dd hh:mm:ss") AS DateString FROM tblNotes;

    qryMaxDateNote
    SELECT [qryMaxDates].[Job Number], [qryMaxDates].MaxOfNoteDate, qryNotesAdj.Notes, qryNotesAdj.NoteDate


    FROM qryNotesAdj RIGHT JOIN qryMaxDates ON (qryNotesAdj.ClientID=[qryMaxDates].[Job Number]) AND (qryNotesAdj.DateString=[qryMaxDates].MaxOfNoteDate);
    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.

  2. #17
    Modify_inc is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    100
    Thank you yet again! I created the three queries and it appears to be working as expected.

    Also, thank you for the SQL code! I'm going to study over it and attempt to make sense of it.

    Thanks June!

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Filter fields including records with null
    By Ruegen in forum Programming
    Replies: 18
    Last Post: 01-28-2014, 11:23 PM
  2. Replies: 3
    Last Post: 05-10-2013, 10:49 PM
  3. Replies: 7
    Last Post: 05-23-2012, 02:19 PM
  4. Blank form on null query results
    By JackieEVSC in forum Forms
    Replies: 11
    Last Post: 11-30-2011, 08:39 AM
  5. saving records without null or empty fields
    By amber mara in forum Access
    Replies: 1
    Last Post: 05-05-2010, 02:34 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