Hello Everyone!
Thx in advance to read and reply my question and thanks to this site for providing opportunity for getting help.
I have main form (FrmFabricReceive) and subform (SFrmTblFabricPieceEntry), I have set code in Subform so that if condition not met it will not run update code, But I failed to write code that stops subform to update its value in its related table (SFrmTblFabricPieceEntry). I can not use beofore update as the Subfrom is in datasheet view and its updating all previously entered values in its table.
this is code that is in after update of subfrom of main form :
Private Sub Form_AfterUpdate()
On Error GoTo Error_Handler
'----------------
Dim aq, aw, au, az
aq = "UPDATE TblGreyFabricOrder "
aw = DSum("[ReceiveGreyFabricMeter]", "TblFabricPieceEntry", "[FabricReceiveID] =" & Forms!FrmFabricReceive!FabricReceiveID)
au = "where TblGreyFabricOrder.GreyOrderID = " & Forms!FrmFabricReceive![GreyOrderID]
aq = aq & " SET TblGreyFabricOrder.TotalGreyReceive =" & aw & " " & au
az = DLookup("[TotalGreyPurchaseInvoiceQuantity]", "TblGreyFabricOrder", "[GreyOrderID] =" & Forms!FrmFabricReceive!GreyOrderID)
If aw > az Then
'Debug.Print aw, az
MsgBox "The Quantity is more than Invoice quantity, this can not be updated."
Me.Undo
Exit Sub
Else
DoCmd.SetWarnings (False)
DoCmd.RunSQL aq
End If
'--------------------
' Before End sub ends, In here couple of update statement that update "TblFabricReceive" but I have removed it to make it simple. but if condition now met in above they won't update the table.
HandleExit:
Exit Sub
Error_Handler:
MsgBox Err.Description
Resume HandleExit
End Sub
Thx in advance to read and reply my question and thanks to this site for providing opportunity for getting help.
I have main form (FrmFabricReceive) and subform (SFrmTblFabricPieceEntry), I have set code in Subform so that if condition not met it will not run update code, But I failed to write code that stops subform to update its value in its related table (SFrmTblFabricPieceEntry). I can not use beofore update as the Subfrom is in datasheet view and its updating all previously entered values in its table.
this is code that is in after update of subfrom of main form :
Private Sub Form_AfterUpdate()
On Error GoTo Error_Handler
'----------------
Dim aq, aw, au, az
aq = "UPDATE TblGreyFabricOrder "
aw = DSum("[ReceiveGreyFabricMeter]", "TblFabricPieceEntry", "[FabricReceiveID] =" & Forms!FrmFabricReceive!FabricReceiveID)
au = "where TblGreyFabricOrder.GreyOrderID = " & Forms!FrmFabricReceive![GreyOrderID]
aq = aq & " SET TblGreyFabricOrder.TotalGreyReceive =" & aw & " " & au
az = DLookup("[TotalGreyPurchaseInvoiceQuantity]", "TblGreyFabricOrder", "[GreyOrderID] =" & Forms!FrmFabricReceive!GreyOrderID)
If aw > az Then
'Debug.Print aw, az
MsgBox "The Quantity is more than Invoice quantity, this can not be updated."
Me.Undo
Exit Sub
Else
DoCmd.SetWarnings (False)
DoCmd.RunSQL aq
End If
'--------------------
' Before End sub ends, In here couple of update statement that update "TblFabricReceive" but I have removed it to make it simple. but if condition now met in above they won't update the table.
HandleExit:
Exit Sub
Error_Handler:
MsgBox Err.Description
Resume HandleExit
End Sub
Attachments
Last edited: