Results 1 to 2 of 2
  1. #1
    Jamesy_007 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Location
    Caribbean
    Posts
    99

    Table Design when DateDiff two DateFields rows_down consecutively

    Good Days Folks... hope you'll are good



    Giving this equation and loop another try can this been down... did this with on date_Field but what if i want to know the difference step down cross fields and rows consecutively ...lol does that statement make sense lol
    ID Names StartDate EndDate DaysReturned
    1 JOHN DOE 14-Jan-19 21-Jun-19
    1 JOHN DOE
    06-Jul-20 11-Mar-20
    2 JOE SUE 01-Apr-29 12-May-29
    2 JOE SUE 15-Sep-20 15-Nov-20
    2 JOE SUE 02-Nov-20 14-Dec-20
    2 JOE SUE 21-Dec-20 12-Jan-21
    1 (D2)ED- (C3)SD
    2 (D4)ED- (C5)SD
    2 (D6)ED- (C7)SD
    Heys guys tried to give table as excel_spread... sorry only way i knew how
    Code:
      Function tblReturnedDays()   Dim db As Database, rst As Recordset
       Dim PrevID As Long
       Dim PrevDate As Date, StartDate As Date
       
    Set db = CurrentDb
     Set rst = db.OpenRecordset("tblReturnedDays")
      rst.MoveFirst
    Do
    PrevID = rst!ID
    PrevDate = rst!EntryDate - StartDate
    rst.MoveNext
    If rst.EOF Then
      Exit Do
      End If
      If rst!ID = PrevID Then
      rst.Edit
      rst!DaysReturned = rst!EntryDate - StartDate
      rst.Update
     End If
    Loop
    rst.Close
    Set rst = Nothing
    Set db = Nothing
    Is this Possible as is... usually i use excel datediff between cells to get an answer Hmmmm and so far much easier but am still trying to figure this out in Ms Access
    Last edited by Jamesy_007; 12-13-2020 at 04:47 PM.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    For query to pull value from another record in same table, review http://allenbrowne.com/subquery-01.html#AnotherRecord
    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. DateDiff result to table field
    By tbjmobile@gmail.com in forum Access
    Replies: 2
    Last Post: 01-04-2018, 03:47 PM
  2. Count values that occur consecutively
    By WickidWe in forum Queries
    Replies: 15
    Last Post: 12-11-2013, 07:19 PM
  3. Table Design -- want to avoid a design that creates blank fields
    By snowboarder234 in forum Database Design
    Replies: 4
    Last Post: 10-08-2012, 10:13 AM
  4. DateDiff Validation in Table
    By stanbridge in forum Access
    Replies: 3
    Last Post: 05-12-2011, 05:03 PM
  5. Filtering results by date between two datefields
    By lakylekidd in forum Programming
    Replies: 9
    Last Post: 06-07-2010, 07:42 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