Results 1 to 13 of 13
  1. #1
    libraccess's Avatar
    libraccess is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Napier New Zealand
    Posts
    129

    Meter Readings Part 2

    This is further to my post the other day
    I'm rebuilding an old DB --pretty well finished the bulk of it but not the meter reading part
    and have been trying to fathom the subquery to put in a start meter reading based on a previous reading. (Note not necessarily "the" previous reading)
    Normally a report is generated to show monthly quarterly or yearly based on Date Selection


    So I have made a pared down db to try and have spent some time on this I can get the meter readings i want in separate reports but bringing it together i would really like some ideas or help please
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    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
    libraccess's Avatar
    libraccess is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Napier New Zealand
    Posts
    129
    Yes i followed your suggestion any query i came up with showed no results

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Try:
    SELECT *, (SELECT TOP 1 Dupe.RAreading FROM tblRALog As Dupe WHERE Dupe.RAassetNoFK = tblRALog.RAassetNoFK AND Dupe.MEndDate<tblRALog.MEndDate ORDER BY Dupe.MEndDate DESC, Dupe.IDRALog) AS PriorReading
    FROM tblRALog;
    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
    libraccess's Avatar
    libraccess is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Napier New Zealand
    Posts
    129
    Yes that works Thanks again for your help

  6. #6
    nmeuvdast8 is offline Novice
    Windows 11 Office 365
    Join Date
    Feb 2025
    Posts
    11
    Quote Originally Posted by June7 View Post
    Try:
    SELECT *, (SELECT TOP 1 Dupe.RAreading FROM tblRALog As Dupe WHERE Dupe.RAassetNoFK = tblRALog.RAassetNoFK AND Dupe.MEndDate<tblRALog.MEndDate ORDER BY Dupe.MEndDate DESC, Dupe.IDRALog) AS PriorReading
    FROM tblRALog;
    I am trying to build a meter reading DB and ran into the same problem. I tried the code above, modified according to my DB but I am getting blank data on the previous readings
    Attached Files Attached Files

  7. #7
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    see Query1
    Attached Files Attached Files

  8. #8
    nmeuvdast8 is offline Novice
    Windows 11 Access 2021
    Join Date
    Feb 2025
    Posts
    11
    Wow! Thanks man! I've been running circles with this for about a week. You are a lofe saver!

  9. #9
    nmeuvdast8 is offline Novice
    Windows 11 Access 2021
    Join Date
    Feb 2025
    Posts
    11
    Quote Originally Posted by jojowhite View Post
    see Query1
    follow up question, how can I get the previous date 2 months prior? example:

    November 15, 2024
    December 14, 2024
    January 3, 2025
    February 12, 2025

    How can I get the result to show December 14, 2024?

    Thanks!

  10. #10
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    i hope there won't be another last 3 month, last quarter, etc.
    see Quer2, which is based on Query1.
    Attached Files Attached Files

  11. #11
    nmeuvdast8 is offline Novice
    Windows 11 Access 2021
    Join Date
    Feb 2025
    Posts
    11
    Thanks man! last question, ow can change the Previous Month and 2 Previous Month to date format?

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Just goes to show, 12 year old threads are still useful.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Quote Originally Posted by nmeuvdast8 View Post
    Thanks man! last question, ow can change the Previous Month and 2 Previous Month to date format?
    Looks like date format to me.

    Keep in mind, instead of hijacking old, existing thread, should start your own. Include reference link to old if you think it can be helpful to explain your situation.
    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: 5
    Last Post: 03-18-2013, 12:31 PM
  2. How Can export Large table part by part
    By shabar in forum Import/Export Data
    Replies: 2
    Last Post: 02-04-2013, 06:29 AM
  3. Meter dillema
    By praetorianprefect in forum Database Design
    Replies: 12
    Last Post: 04-13-2012, 07:22 AM
  4. Replies: 5
    Last Post: 03-25-2012, 03:27 AM
  5. WHERE as part of JOIN not after
    By thestappa in forum Queries
    Replies: 1
    Last Post: 05-14-2010, 10:52 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