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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculation on Changed Record

Status
Not open for further replies.

FrankPV

Technical User
Oct 11, 2000
20
US
I'm using an Access form field (Quantity) to perform a calculation if the user changes the field. The problem is when I try to use the field to perform the calculation it is pulling the old value, not the changed value. How do I reference this updated value to use in the calculation after the user changes it?

Thank you.
 
What event are you using? If you use the afterupdate event you should get the new value. Also, post your code if you want meaningful help--it's hard to know what to tell you if we can't see what you're doing.

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
I'm using the On Change Event for the Quantity Field. The code I'm attempting to execute is as follows:

Private Sub QUANTITY_Change()



Dim lngInvItemID As Long, lngPOItemID As Long, lngQuantity As Long
Dim receivedqtytest As Long
Dim rst As Recordset
Dim qtytest As Long


qtytest = Me.QUANTITY.Value
lngInvItemID = Me.ItemID
lngPOItemID = Me.POItemID
lngQuantity = Nz(Me.QUANTITY, 0)

'check that user did not move focus on subform to different po item than what is on the invoice screen
If Me.POItemID <> Me.sbfPO_List_Box_Items.Form.ItemID Then
Set rst = Me.sbfPO_List_Box_Items.Form.Recordset
rst.FindFirst &quot;[ItemID] = &quot; & lngPOItemID
End If
Me.sbfPO_List_Box_Items.Form.ReceivedAmt = UpdateReceivedQuantity(lngInvItemID, lngPOItemID, lngQuantity)

receivedqtytest = Me.sbfPO_List_Box_Items.Form.ReceivedAmt


If Me.sbfPO_List_Box_Items.Form.ReceivedAmt >= Me.sbfPO_List_Box_Items.Form.QUANTITY Then
Me.sbfPO_List_Box_Items.Form.Received = True
Else
Me.sbfPO_List_Box_Items.Form.Received = False
End If

Me.FREIGHT.SetFocus
Me.InvoiceTotal.Requery
Me.txtNewInvoiceTotalFreight.Requery

The problem I'm having is the value I want to use for lngQuantity is the changed value. The value the code is currently using is the original value. How do I retrieve the changed value for the quantity field for use in these calculations?

Thank you.
 
Use the afterupdate event.

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top