Help with Code so that values calculated on form be updated on the table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please, I need some help..
I have fields that results from calculation based on fields entered on this same form. The problem is that I need to update the table with these results. I guess the codes must go to the AfterUpdate for these fields on the form which results from calculation- but I don't know how to prepare the codes.
 
Hi:

You could use the Form_BeforeUpdate event as well.

Create a field in table says "CalcResult" to store the result of your
calculation in the table to which your form is bound.

In the Form_BeforeUpdate event you could just type.

Me.CalcResult = [Qty]*[Price] 'here [Qty]*[Price] is teh calc you need.

However note that calculated fields are generally not stored in a table as
they can always be calculated in a query. Moreover if user changes anything
at the table level itself then the calcuated field will not change.

Regards,

Naresh Nichani
Microsoft Access MVP


Andrea said:
Please, I need some help...
I have fields that results from calculation based on fields entered on
this same form. The problem is that I need to update the table with these
results. I guess the codes must go to the AfterUpdate for these fields on
the form which results from calculation- but I don't know how to prepare the
codes.
 
Hi Naresh
I gave the same name to the field on the table as the name of the field that stores the result on the form. I set BeforeUpdate event the way you explained. But somewhere I lost a link because I have a list of text boxes whose data I set and others whose date are calculated. Those whose data are calculated from values entered on others textboxes show "#Name?" when the form runs
Maybe it would be useful if I say that those fields are inside an Option Group. I mean- if I choose the first option, a list of fields must appear, and If I choose the other, then another list appears. Each of these lists contains fields whose value I can set and others that result from calculation based on those ones I've set. Both options present "#Name?" for the fields whose value is result from a calculation..
 
Back
Top