I want to be updating a control called currentstock whenever I launch a query below instead of me doing it manually to avoid mistakes. At the moment the update is put on afterevent in the subform and it fires immediately I change the quantinty but does not fire if I requery the data unless I go back and retype the quantity again. This is not good for us to avoid mistakes such typing different a figure instead of the original figure.
This work okay at creation stage
The problem comes when you to do an automatic reversal of the same figures it does not fire at all, such that after retrieving the figures by using the query below you have to update the current stock manually
I tried to put the code below on dirty again it does nothing
This work okay at creation stage
Code:
Private Sub Quantity_AfterUpdate()
Me.CurrentStock = Nz(Me.CurrentStock, 0) + Nz(Me.Quantity, 0)
End Sub
The problem comes when you to do an automatic reversal of the same figures it does not fire at all, such that after retrieving the figures by using the query below you have to update the current stock manually
Code:
Private Sub CboReverseInvoice_AfterUpdate()
On Error GoTo Err_Handler
Dim LTAudit As String
LTAudit = Nz(DLookup("intrlData", "tblCustomerInvoice", "InvoiceID =" & Me.CboReverseInvoice))
Me.Filter = "InvoiceID = " & Me!CboReverseInvoice.Value & ""
If (LTAudit <> "") Then
Beep
MsgBox "This document is already approved cannot be edited", vbOKOnly, "Internal Audit Manager"
Me.FilterOn = False
Else
Me.FilterOn = True
End If
Dim Records As DAO.Recordset
Set Records = Me![sfrmLineDetails Subform].Form.RecordsetClone
If Records.RecordCount > 0 Then
Records.MoveFirst
While Not Records.EOF
Records.Edit
Records.Update
Records.MoveNext
Wend
End If
Records.Close
Exit_CboReverseInvoice_AfterUpdate:
Exit Sub
Err_Handler:
MsgBox Err.Number & Err.Description, vbExclamation, "Error"
Resume Exit_CboReverseInvoice_AfterUpdate
End Sub
I tried to put the code below on dirty again it does nothing
Code:
Me.CurrentStock = Nz(Me.CurrentStock, 0) + Nz(Me.Quantity, 0)