View Full Version : Update Accumulated Field


Randomblink
10-02-2001, 11:35 AM
Ok...
I have a database that holds data on the various projects that my department take on for the city where I live...

I have a form with two subforms...
Form.frm_Project Adjustments
subform.frm_Change_Order
subform.frm_Contract_Amendments

Ok...
The main forms holds Project data, for instance, the HVAC Construction/Repair at a Firestation...
Inside that project, there might be: Change_Orders or Contract_Adjustments...

Let's say that on the HVAC project there are two Change_Orders...each Change_Order is for a specific amount...$15,000 for one and $120,000 for the other...

What I want is for a field on the 'main' form to add this up and store it...

So in the above example...as I type in:
CHG_ORDER # CHG_ORDER $ JUSTIFICATION
----------- ------------ -------------
1 $15,000 Supplies
2 $120,000 Labor

I want a field on my main form labeled: Accumulated Change Order to automatically display and store in the database the amount of $135,000...

So, to do this, I have set the main forms On_Dirty event to do this...

Me!CHGORDAMTMN = SUM(Forms!frm_Change_Order!CHGORDAMT)
Me!AMNDMT = SUM(Forms!frm_Contract_Amendments!AMDAMT)

CHGORDAMTMN is the Accumulated Change Order field on the main form...
and AMNDMT is the Accumulated Contract Amendment field on the main form as well...

I should mention, that the subforms and related fields are in tabs on my main form...(in case that matters)

What happens now is...NOTHING...

I have changed it to the forms After_Update event with no difference...

What can I do...?

The database is huge now, with a front-end and a back-end, it runs nice, but I really want to make this work...

Thanks in advance...

jwindon
10-02-2001, 03:31 PM
To sum the subform change order totals, put an unbound textbox on your subforms footer with the control source

=Sum([AmountofChangeOrder])

To show the original contract price, Use dlookup to show it...an unbound text box with :

=DLookUp("[Amount]","tblContracts","[ContractNo]=Forms!subformName![ChangeOrderID]")

Then yet another unbound box to calculate the AMMENDED CONTRACT amount...however, I'm still working on getting that right. Maybe someone else can help while I work.




[This message has been edited by jwindon (edited 10-03-2001).]

Randomblink
10-03-2001, 04:54 AM
Thanks for the help, but unfortunately, Im an Oklahoman...sorry man...
I do know how you got confused tho...
In a post a month or so ago, one that I believe I started or was involved in, another guy popped in saying he was from Kentucky too, I remember the two of you chatting about Kentucky...lol
So, thanks for the help, and I am still working on it...
Anyone else got any ideas...?

Rich
10-03-2001, 11:29 AM
It's generally not considered good practice to "store" calculated fields without some good way of ensuring the integrity of your data, do you have those procedures in place?