
Are you sure that DSum() is producing a value? What is in Me.POID? Is your form bound to tblPO? Storing calculated values is against normalization rules and not recommended. Why do you want to do it?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Dear all,
I have 2 tables. One TblOutput have some fields: PONumber, OKQty, Process. And one table TblPO have fields: POID, ActualQty that i take them into one Subform.
When I open the form, The Dsum will calculate from TblOutput and update on tblPO. I write the VBA code as below but I dont see any update. Please help me whether code is correct or not?
Private Sub Form_Load()
On Error GoTo ErrorHandler
Dim sql As String
Dim rs As DAO.Recordset
sql = "SELECT * FROM TblPO where lock = No"
Set rs = CurrentDb.OpenRecordset(sql)
With rs
If Not .BOF And Not .EOF Then
If .Updatable Then
.Edit
![ActualQty] = DSum("[OKQty]", "TblOutput", "[Process]='Final_Inspection'" And "[PONumber]= Me.POID")
.Update
End If
End If
.Close
End With
ExitSub:
Set rs = Nothing
Exit Sub
ErrorHandler:
Resume ExitSub
End Sub
Are you sure that DSum() is producing a value? What is in Me.POID? Is your form bound to tblPO? Storing calculated values is against normalization rules and not recommended. Why do you want to do it?