Reputation: 377
I have the following code on an OnCurrent Event in a subform:
Private Sub Form_Current()
Me.Parent![QUOT_TOTAL] = DSum(" Q_SUB ", "DSUM_Q_SUB")
Me.Parent![QUOT_TOTAL].Requery
Me.Parent![QUOT_DISC] = (Me.Parent![QUOT_TOTAL] * Me.Parent![DISCOUNT_PERCENT]) / -100
Me.Parent![QUOT_DISC].Requery
End Sub
As soon as I open the form I get error 2448 cannot assign a value to this object. When I close the warning the form works OK.
The OnCurrent event is assigned to the subform of a parent form and the fields I want to update (as shown above) [QUOT_TOTAL] and [QUOT_DISC] are on the parent form. They are found as columns on a table but I want the form to update these as soon as changes on the subform occur.
Kindly help
thanks
Elton
Upvotes: 0
Views: 1456
Reputation: 4808
In the case of QUOT_TOTAL
, if its value should always be QTY
x PRICE
I wouldn't store it at all (i.e., I'd remove the field from the table), and assign the text box's Control Source property the expression =QTY * PRICE
; if however that calculation is just the default value that could be overridden, keep the field and assign =QTY * PRICE
to the control's Default Value property. You can do something similar for QUOT_DISC
with the expression =DISCOUNT_PERCENT / -100 * QTY * PRICE
. That said, the use of the subform might still upset this...
Upvotes: 1