Results 1 to 3 of 3
  1. #1
    coffman34 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    1

    Daily usage query

    I have a table that has multiple energy use readings throughout the day. So each day may have multiple readings.

    How do I create a query to show daily usage?

    I need to subtract the max record of X day from the max record from the previous day to ensure I include overnight usage (when no readings are taken).

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    on a form, put a text box for current date, txtDate (date picker)
    put a text box for prev date, txtPrevDate
    txtPRevDate = DateAdd("d",-1,txtDate)

    select the date.
    Q1: select Max(reading) as PrevVal from table where [dateval]=forms!myForm!txtPrevDate
    Q2: select Max(reading) as CurrVal from table where [dateval]=forms!myForm!txtDate
    Q3: ,select Q2.CurrVal - Q1.PrevVAl from Q1,Q2

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Kinda slim on info..... but it soulds like you will need a sub query to get the data.
    You should see this about sub queries:

    Get the value in another record
    http://www.allenbrowne.com/subquery-...#AnotherRecord

    Using this page, I was able to create a "Mileage" dB (using Access 97) to calculate/track mpg, cost & number of days between fill ups.

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

Similar Threads

  1. Replies: 4
    Last Post: 11-10-2015, 01:11 PM
  2. Replies: 3
    Last Post: 05-23-2014, 07:50 AM
  3. query usage in a form
    By sherik in forum Forms
    Replies: 2
    Last Post: 04-21-2013, 03:45 PM
  4. Access Newbie - Query for Daily Subtotals?
    By malikastor in forum Access
    Replies: 3
    Last Post: 01-09-2012, 09:11 PM
  5. Creating a Daily Running Total Query
    By seraph in forum Queries
    Replies: 0
    Last Post: 08-15-2009, 12:11 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