Log in

View Full Version : Running Average calculation on the forms



sindhuja
07-29-2009, 01:16 PM
Hi....

I have a form where we enter production records 1, production records 2, production records 3. We also enter other fields.... Just wondering if it's possible to create a calculated field on the form that would show what the production average for each production records for the past month is and a field that shows how the current entry affects that average. Basically, it would be nice if they could see a running average as they enter the production. I'm sure I can do that on a form.


-Sindhuja

OBP
07-30-2009, 03:08 AM
Sindhuja, the easiest way to achieve your Average is to use a Query to calculate it and a very small Subform to display it on the Main Form. Just Requery the Subform each time a change is made to the values.

sindhuja
07-30-2009, 05:55 AM
Thanks for the sugession.. let me give a try ….

But I need to compare the today’s entry with average of pastmonth.. [for ex todays average value is for the dates 7/29 to 6/29 then tomorrow the average values should be for 7/30 to 6/30] am not sure how get the date range………..

So for comparision if I have both the entries on the same form then that will be more helpful for me.
If the value I enter today is of much difference say + or – 20 of the average value then I need the todays textbox to be colored [something like alarm to the user]…

Have been struggling with this requirement for a quite long time….
any sugessions pls…

-sindhuja

OBP
07-30-2009, 07:52 AM
You can set the date criteria in the Query, is it always 1 month or would 30 days do?
You can have both values on the form at the same time.
Can you provide some dummy data?

sindhuja
07-30-2009, 10:49 AM
Hi..

Attached is the sample which am currently using… I will be filling the details as per the accounts.
Now I need to insert a textbox for each entry which will display the average.

Frmdetails - form with dummy textbox
Tbldetails – table in which I have entered dummy datas just for days. Now the challenge is to get the running date as criteria for finding the average…

Your help is highly appreciated…

-sindhuja

OBP
07-31-2009, 04:35 AM
sindhuja, do you need averages of the fields S1 to S10?
I am concerned that those fields should be in a separate table as individual records.

sindhuja
07-31-2009, 09:33 AM
No, I need average of S1 for the specific account say A1 in the date range for example 7/27/09 to 7/31/09 today and the date range should change tomorrow as 7/28/09 to 8/1/09 and goes on……

I have set up a table with all these fields together..

-Sindhuja

OBP
08-01-2009, 03:11 AM
So the Account needs to be the same as the Account in the Record on the Form?
Will 30 days averaged out be OK as getting the Exact "Month's" worth of days in a Query is proving to be very difficult/

sindhuja
08-03-2009, 01:41 PM
yes it should be same as in the form... and 30 days average will do..

OBP
08-04-2009, 08:46 AM
Ok this form now has a subform showing the average of S1 for the last 3 days for each Account you move to in the main form records

sindhuja
08-04-2009, 01:36 PM
Thanks a lot..

It seems to be confusion for the comparison purpose.
I want the average of S1 for the account A1 in the average box of S1.
This should be filled at the time of form open. Once I enter the count of S1 in todays box then It should compare with the average and act accordingly.

-Sindhuja

OBP
08-05-2009, 04:27 AM
I had not added the Comparison, I wanted to make sure the Average was what you needed.

OBP
08-05-2009, 04:44 AM
Try this, you can modify the Values and messages in the After Update Event procedure of the S1 field.

sindhuja
08-05-2009, 02:06 PM
Hi OBP,

Am almost done with my requirement…
Now all I have to do is compare the todays value with the average of the account and change the color of todays textbox accordingly.

-Sindhuja

OBP
08-06-2009, 03:41 AM
What Colours do you want?

sindhuja
08-06-2009, 08:03 AM
Any color to differentiate between two text box...

-sindhuja