PDA

View Full Version : Migrating the value of a formula in a subform's VBA to a value within a Table object



arkangel_007
12-05-2014, 03:18 PM
I am trying to get the result a formula that calculates an order subtotal after a discount to be used as the recorded subtotal value of an order on my Orders Tbl.

Here is the code so far, the error occurs on the last line.

Note: The 'subtotal' is supplied from an expression that sums the fields in a subform. That expression is =sum(lineitemextendedprice)



Private Sub Command79_Click()

Dim subtotal As Double

Dim subafterdiscount As Double

Dim discount As Double

subtotal = Me.Text76

discount = DLookup("[discountQuantity]", "tblDiscounts", "[discountID] = " & Forms![frmnewOrder].[Combo16].Column(2))

subafterdiscount = (1 - discount) * (subtotal)

Forms![frmnewOrder].[Text59] = subafterdiscount


tblOrder.orderSubTotalCharged = subafterdiscount <--ERROR OCCURS HERE (This is where I tried to set the value of the attribute equal to the variable)


End Sub


Any Help is appreciated!

jonh
12-09-2014, 03:11 AM
Either use an update query or link a control to the field and set its value.