Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Anugerah is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    15

    Call back data from 1 day before


    Hi, I'm still quite new in access.

    So, I already have a query that contain vehicle milage recorded per day on each record.
    I want to create a new field containing milage recorded from 1 day before each record so I could have milage usage data.
    Please help me providing the solution for this issue.

    Thank you

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Attached is an older .mdb practice db that I have kept to demonstrate what you are looking for.
    Attached Files Attached Files

  4. #4
    Anugerah is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    15
    This is my query.
    So I couldn't use ID because all the equipment is mixed here.
    I need formula for another field that look up the hourmeter 1 day prior to maintenance date for each equipment
    Click image for larger version. 

Name:	query.png 
Views:	18 
Size:	22.1 KB 
ID:	31962

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The ID is probably equivalent to your inventory number. It makes sure your getting the previous reading for the correct item.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Anugerah is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    15
    Quote Originally Posted by pbaldy View Post
    The ID is probably equivalent to your inventory number. It makes sure your getting the previous reading for the correct item.
    No, the ID isn't equivalent with inventory number.
    So I want to call again the hourmeter record 1 day before each record, and of course from the record with the same inventory number

    FYI.

    The inventory number here is mixed up so does the ID

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Use your inventory number in place of the address ID in the link. Attach your db here if you're not understanding.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Why not a record ID to your table?

  9. #9
    Anugerah is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    15
    I even tried to make strings from date and prior date like this

    Click image for larger version. 

Name:	query.png 
Views:	15 
Size:	34.6 KB 
ID:	31972

    This is the formula I use for Prior HM

    PriorHM: DLookUp("[Hourmeter]";"Hourmeter Usage";"Inventory Number=" & [Inventory Number] And "Prior Date String=" & [Maint Date String])

    But, still can't get it right

  10. #10
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    You don't appear to have used Allen Browne's approach (meter reading example) which involves a subquery

    You haven't said how you created the additional fields
    If you have a routine to do that automatically using a function or query, that may be acceptable, but not if you have to enter the records manually

    Anyway, your expression fails as both field in the lookup are text strings so you need text delimiters

    PriorHM: DLookUp("Hourmeter";"Hourmeter Usage";"Inventory Number='" & [Inventory Number] & "' And Prior Date String='" & [Maint Date String] "'")

    Suggest you don't name text fields with Number as part of the field name!
    Last edited by isladogs; 01-08-2018 at 04:04 AM.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by ridders52 View Post
    PriorHM: DLookUp("Hourmeter";"Hourmeter Usage";"Inventory Number='" & [Inventory Number] & "' And Prior Date String='" & [Maint Date String] * "'")
    You missed brackets on objects with inadvisable spaces in the names.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Quote Originally Posted by pbaldy View Post
    You missed brackets on objects with inadvisable spaces in the names.
    Hi Paul

    Oops
    You are of course right but for some reason you didn't post the corrected version which is (I hope):

    Code:
    PriorHM: DLookUp("Hourmeter";"[Hourmeter Usage]";"[Inventory Number] = '" & [Inventory Number] & "' And [Prior Date String] = '" & [Maint Date String] "'")
    In my defence I just copied the OP's code & added text delimiters .....
    Just the 3 errors! Having a bad hair day here!
    Last edited by isladogs; 01-08-2018 at 04:03 AM.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by ridders52 View Post
    for some reason you didn't post the corrected version
    I was on a mobile device, too tedious (or lazy) to edit code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    But luckily not too 'lazy' to point out the errors. Thanks again
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  15. #15
    Anugerah is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    15
    Thank you for all your help. I don't know why but the code I copied from here doesn't work well.
    Finally I tried some modification and this is the code that works for me.

    PriorHM: DLookUp("[Hourmeter]";"[Hourmeter Usage]";"[Inventory Number] = '" & [Inventory Number] & "' AND [Maint Date String]= '" & [Prior Date String] & "'")

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

Similar Threads

  1. Call data into subform within a form
    By pwelch in forum Forms
    Replies: 4
    Last Post: 03-30-2017, 09:36 AM
  2. Replies: 1
    Last Post: 03-02-2015, 09:44 AM
  3. Replies: 4
    Last Post: 05-21-2012, 08:21 AM
  4. Replies: 4
    Last Post: 11-06-2009, 09:51 AM
  5. Call Excel Data into Access table
    By jiguvaidya in forum Import/Export Data
    Replies: 0
    Last Post: 09-15-2008, 04:58 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