For a meter readng system, I am having a problem using the current reading less the previous reading to calculate the net. My issue is more of a problem depicting previous reading and the calculated net value for the the current record / row in a continous form.
We track utility meter readings for gas, water, electricity, etc for a plant -- there are dozens of meters read every day. We have grown way beyond using Excel (I am sure you have heard this one before). Although Access does a much better job of tracking meters, I am finding it awkward to caclulate the net daily consumption -- something that is a piece of cake in Excel.
Sure, I can store the previous reading along with the current reading but two issues ... 1) breaks normalization rule, and 2) a data entry error or missed entries can be more problematic to fix. I would prefer to store the current reading only, find the previous reading when needed (report or form) and then calculate the net.
I have tried a complex nested select statement -- works for a single record, but not for a continous form.
I have tried using an array - calculates the numbers correctly, but does not display properly.
Both the "select" and "array" attempts failed for the same reason -- Access uses the current or last record to display the same calculated value to each line of the continous form. For example, 961,000 is displayed on every row for the prevous reading. (Yep - some of you have been here.)
From the history file, I have...
fldHistory_id, fldMeter_id, fldRead_date, fldReading
In addition, on the form, I have fields using an unbound control source or a select statement as a control source (tried both) for...
fldPrev_reading
And then the calculated field...
fldNet
I guess my next path will be to use a temp table, but I was hoping for a less messy solution. (Temp files, add / delete records would suggest more DB maintenance would be required more frequently. Plus logic to avoid data conflict from other users.)
I suppose an alternate would be to use non-continous form and manually manipulate the array. Again messy, and I am not sure how the code would work when creating the reports.
Any ideas?
Richard
We track utility meter readings for gas, water, electricity, etc for a plant -- there are dozens of meters read every day. We have grown way beyond using Excel (I am sure you have heard this one before). Although Access does a much better job of tracking meters, I am finding it awkward to caclulate the net daily consumption -- something that is a piece of cake in Excel.
Sure, I can store the previous reading along with the current reading but two issues ... 1) breaks normalization rule, and 2) a data entry error or missed entries can be more problematic to fix. I would prefer to store the current reading only, find the previous reading when needed (report or form) and then calculate the net.
I have tried a complex nested select statement -- works for a single record, but not for a continous form.
I have tried using an array - calculates the numbers correctly, but does not display properly.
Both the "select" and "array" attempts failed for the same reason -- Access uses the current or last record to display the same calculated value to each line of the continous form. For example, 961,000 is displayed on every row for the prevous reading. (Yep - some of you have been here.)
From the history file, I have...
fldHistory_id, fldMeter_id, fldRead_date, fldReading
In addition, on the form, I have fields using an unbound control source or a select statement as a control source (tried both) for...
fldPrev_reading
And then the calculated field...
fldNet
I guess my next path will be to use a temp table, but I was hoping for a less messy solution. (Temp files, add / delete records would suggest more DB maintenance would be required more frequently. Plus logic to avoid data conflict from other users.)
I suppose an alternate would be to use non-continous form and manually manipulate the array. Again messy, and I am not sure how the code would work when creating the reports.
Any ideas?
Richard