Results 1 to 4 of 4
  1. #1
    pio92 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    19

    SET value to next record in group

    Hi,


    I looking for a SQL-Query (MS-Access O365) ,which:


    If status is "in"
    then the next record with the same F7 receives value "out"

    Click image for larger version. 

Name:	11.JPG 
Views:	16 
Size:	23.0 KB 
ID:	47169
    Click image for larger version. 

Name:	11a.JPG 
Views:	15 
Size:	41.6 KB 
ID:	47168

    I want updating so my table.
    In this table are more "groups" with difficult F7 value

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,942
    If "in" has just been entered, why not just move to next record and type "out"?

    I very much doubt SQL alone can accomplish and will require VBA procedure. However, is not clear to me what exactly you want to accomplish, what process you want to automate. Do you want to update entire table?

    You show table in image. Any programmatic solution would have to be initiated by an event, perhaps button click on form.
    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
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,432
    then the next record with the same F7 receives value "out"
    you need to be clear what you mean by 'next record' - I assume it would that be based on F14 - so the next record in time and not next record that was entered (probably based on ID), regardless of time. Your example is simplistic so either basis could work.

    Also need to clarify what happens with the other records - would appear from your example that 'in' is already populated so you only want to populate the next record (ID=4) - what if record 6 was populated with 'in'? - there is no next record.

    what happens if you subsequently edit record 3 and change the time to a later time? or remove or change the status? or change record 4 to an earlier time? or add a new record with a time between those of records 3 and 4?

    Agree with June - this cannot be automated in a table, you will need to use a form and vba. What that vba looks like depends on clarifying what you are trying to do

  4. #4
    pio92 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    19
    Quote Originally Posted by Ajax View Post
    you need to be clear what you mean by 'next record' - I assume it would that be based on F14 - so the next record in time and not next record that was entered (probably based on ID), regardless of time. Your example is simplistic so either basis could work.

    Also need to clarify what happens with the other records - would appear from your example that 'in' is already populated so you only want to populate the next record (ID=4) - what if record 6 was populated with 'in'? - there is no next record.

    what happens if you subsequently edit record 3 and change the time to a later time? or remove or change the status? or change record 4 to an earlier time? or add a new record with a time between those of records 3 and 4?

    Agree with June - this cannot be automated in a table, you will need to use a form and vba. What that vba looks like depends on clarifying what you are trying to do
    I resolved it with VBA FindFirst, FindNext DAO Function

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

Similar Threads

  1. Group by then Unmatch record
    By mks123 in forum Access
    Replies: 6
    Last Post: 07-15-2018, 11:43 AM
  2. Replies: 1
    Last Post: 05-13-2015, 10:04 AM
  3. Random Record Within Group
    By warrenk in forum Queries
    Replies: 2
    Last Post: 10-21-2013, 02:17 PM
  4. group record by months
    By Compufreak in forum Access
    Replies: 3
    Last Post: 08-03-2012, 05:11 AM
  5. Sum only first record of group
    By RogerC in forum Access
    Replies: 3
    Last Post: 07-18-2012, 10:19 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