Results 1 to 5 of 5
  1. #1
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172

    Trying to query 2 records in a query with same name

    Hi, I have a query, and the results are:



    Facility_Name Audit_Date Audit_Due_Date

    Facility1 01-Jan-2012 01-Apr-2012
    Facility1 05-Apr-2012 05-Jul-2012

    So, an audit is due every 3 months, but for Facility1, the 2nd Audit was due on 01-Apr, but didn't happen until 05-Apr, so therefore it was 4 days overdue.

    This is what I want to calculate, but I just can't figure out how to do it!

    Any help much appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You want to calculate how many days the actual audit date was past the first of the month?

    [Audit_Date] - CDate(Month([Audit_Date]) & "/1/" & Year([Audit_Date]))
    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
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Hi June,

    I want to calculate how many days the actual audit date was past the audit due date (not necessarily due on the 1st of the month).

    The issue is that the data is on 2 different rows in the query results. So, [Audit_Date] on row 2 of the query result minus [Audit_Due_Datae] on row 1 of the query result.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You want to pull value from another record. Need a subquery. One method is shown in http://allenbrowne.com/subquery-01.html
    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
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Ha! Perfect, thanks June, you've solved my problem again!

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

Similar Threads

  1. Replies: 3
    Last Post: 01-05-2012, 12:04 PM
  2. query won't display records with no related records
    By James Brazill in forum Queries
    Replies: 1
    Last Post: 06-28-2011, 02:10 AM
  3. Replies: 1
    Last Post: 06-27-2011, 11:58 AM
  4. First x records in query
    By rici7 in forum Queries
    Replies: 4
    Last Post: 06-15-2011, 06:43 AM
  5. Date function to query records and Sum records
    By sullynivek in forum Queries
    Replies: 0
    Last Post: 04-05-2011, 08:37 AM

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