Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which event to autofill calculated fields?

Status
Not open for further replies.

TTThio

Programmer
May 3, 2001
185
US
Could someone let me know how to autofill calculated fields in a subform (datasheet view with more than one record)?

I have a main form with cbobox. Selection will determine which records to display in the subform. Then there'll be calculations perform on each record.

I try to call the procedures on form_current event,
exp. Form_current()
CalculateBonus
CalculateCommission

but calculation will just be executed when I move between records. The only result shown automatically when the subform is requeried is just for the first record.

Which event is supposed to be triggered?

Thanks a lot,

Tin Tin
 
Have you tried building the calculations into the textboxs' control source? ljprodev@yahoo.com
ProDev
MS Access Applications
 
Lonnie's option is probably the best one. However, if that doesn't work for you, you should call the calculation functions from the After Update event on each of the fields that go into the calculation.

For instance, if your commission is based on sales price and volume, in the after update event for sales price, add CalculateCommission(). Likewise for the volume field. Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
Thanks guys.

My calculation cannot be set as the control source. It's a little more complex as a lot of criteria involved.

AfterUpdate event occurs when new changed data in the control or record is updated. Yet, what I'm doing is
when I change the cbobox value in the main form, I requery the underlying data of the subform and perform new calculation without changing any data.

I've tried these 2 ways, none worked out.

So, right now I'm using recordset to perform the calculation by navigating on each record on the recordset.

I have 2 forms which setting are alike, except that the underlying queries is different.

This method works on one form, but acts strange on the other.

I make a new thread about this topic.

Tin Tin

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top