Calculating consumption (1 Viewer)

HeshamHatem

Registered User.
Local time
Tomorrow, 00:33
Joined
Mar 10, 2018
Messages
23
JHB, My superhero

Sorry for not giving you full info from the beginning as I totally forgot that i took copy of the consumption and not the equation :eek::eek:

The example attached has the data stored vertically with the Constants attached.


I have unlimited faith in you my friend and thanks for your efforts.:D:D
 

Attachments

  • Example.xlsx
    14.4 KB · Views: 104

JHB

Have been here a while
Local time
Today, 23:33
Joined
Jun 17, 2012
Messages
7,732
Replace with the below, and check the calculation:
Code:
    dbs.Execute ("SELECT tblReading.ReadingDate, tblReading.CounterName, tblReading.CounterReading, " _
    & "([CounterReading]-(select top 1 [CounterReading] from tblReading as b where b.ReadingDate< tblReading.[ReadingDate] " _
    & "AND tblReading.[CounterName]=b.[CounterName] order by b.ReadingDate DESC))*[CounterConstant] AS Cou Into TempTbl " _
    & "FROM tblCounterName INNER JOIN tblReading ON tblCounterName.CounterName = tblReading.CounterName " _
    & "WHERE Active=True")
 

HeshamHatem

Registered User.
Local time
Tomorrow, 00:33
Joined
Mar 10, 2018
Messages
23
Tanks a lot my friend.

will try it in couple of hours and get back to you buddy
 

HeshamHatem

Registered User.
Local time
Tomorrow, 00:33
Joined
Mar 10, 2018
Messages
23
JHB

I tried it but it missed up the whole calculation and started showing negative figures with totally wrong answers.

I added the counterconstant in the counterName table.

Now what ?
 

JHB

Have been here a while
Local time
Today, 23:33
Joined
Jun 17, 2012
Messages
7,732
Sorry I've forgotten to tell you to create an extra field, so I'll attached the database again.
 

Attachments

  • Database1-25-1.accdb
    548 KB · Views: 108

JHB

Have been here a while
Local time
Today, 23:33
Joined
Jun 17, 2012
Messages
7,732
You're welcome, good luck. :)
 

Users who are viewing this thread

Top Bottom