Hi
I have this update query that is triggered by an after update event on a main form. The record being updated are in a continuous subform. It works well except from the last added/modified record. If I save and close the form and then open it again it works for all records but if modify or add a record, the update query will not work for that last modified/added record.
I have tried several things such as save record, use dirty = false for the on exit event of the subform control but nothing works. Here is the procedure:
Hope someone can help!
I have posted this on other forums without results.
I have this update query that is triggered by an after update event on a main form. The record being updated are in a continuous subform. It works well except from the last added/modified record. If I save and close the form and then open it again it works for all records but if modify or add a record, the update query will not work for that last modified/added record.
I have tried several things such as save record, use dirty = false for the on exit event of the subform control but nothing works. Here is the procedure:
Code:
Private Sub cboPoCurrency_AfterUpdate()
On Error GoTo ErrHandler
Dim db As Database
Dim strSql As String
Dim lngID As Long
Dim dblRate As Double
Set db = CurrentDb
DoCmd.RunCommand acCmdSaveRecord
lngID = Me.txtID
dblNCostR = DLookup("ExRate", "Currency", "ID = " & [cboPoCurrency])
dblRate = dblNCostR / dblOCostR
DoCmd.SetWarnings False
strSql = "UPDATE QuoteLineItems SET QuoteLineItems.UnitCost = [UnitCost] * " & dblRate & _
" WHERE QuoteLineItems.QuoteID = " & Me.txtID & ";"
DoCmd.RunSQL strSql
Me.txtPOExchRate.Value = dblNCostR
Set db = Nothing
ExitSub:
Exit Sub
ErrHandler:
Call ErrorAlert
Resume ExitSub
End Sub
Hope someone can help!
I have posted this on other forums without results.