Results 1 to 4 of 4
  1. #1
    bigern87 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    8

    Query to get data criteria but also want records before and after

    So I have a query which is pulling data that has been sorted by Clock number then by a field called "gap minutes" which I created to determine a gap between two timed transactions performed by the given clock number. I have all the records numbered with an ID if that helps my problem: I need to get the records before and after these queried results. Attached is the query I am using now in design view. This only shows me any gap minutes over 15 minutes. I need to see these records as well as the records immediately before and after. Let me know if you can help.
    Attached Thumbnails Attached Thumbnails Snap1.jpg  

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,603
    Nested subquery might be solution. Review http://allenbrowne.com/subquery-01.html
    Look at example for Get the Value in Another Record.
    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
    bigern87 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    8
    So there are no solutions to this without using SQL? I was hoping for a solution within Access functionality that does not involve much code. Here is the Query as a SQL code, what would I need to implement to achieve this?

    SELECT MONDAY.ID, [133 Employees].[Last Name], [133 Employees].Shift, MONDAY.Date, MONDAY.Time, MONDAY.[GAP Minutes], MONDAY.TRANS_CD, MONDAY.FROM_LOC, MONDAY.TO_LOC, MONDAY.PART, MONDAY.QTY
    FROM [133 Employees] INNER JOIN MONDAY ON [133 Employees].Clock = MONDAY.CLOCK
    WHERE (((MONDAY.[GAP Minutes])>15))
    ORDER BY [133 Employees].[Last Name], MONDAY.[GAP Minutes] DESC;

    This code should be identical to what the design view attachment provides. Let me know if you can help.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,603
    Did you try creating the nested query per the example? Can use the SQL View of query designer to write the statement.

    Other solutions could involve multiple queries or VBA code.
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-31-2012, 01:56 PM
  2. Replies: 1
    Last Post: 07-01-2012, 09:55 AM
  3. Query Criteria not returning any records
    By SgtSaunders69 in forum Access
    Replies: 2
    Last Post: 12-19-2011, 07:45 PM
  4. Replies: 3
    Last Post: 10-25-2011, 11:38 PM
  5. Query: How To Filter Data In Criteria
    By netchie in forum Queries
    Replies: 1
    Last Post: 08-31-2011, 01:36 PM

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