I'm using MS Access 2007 and VBA. I have a block of code which triggers when the quantity is greater than stock or the stock is zero.
Private Sub Quantity_BeforeUpdate(Cancel As Integer)
If Me.Quantity > Me.Stock Or Me.Stock = 0 Then
MsgBox "Not enough stocks left."
Me.Quantity = ""
End If
End Sub
The message box appears but after that an error message followed:
Run-time error '2147352567 (80020009)':
The macro or function set to BeforeUpdate or ValidationRule property for this field is preventing Microsoft Office Access from saving the data in the field.
How to stop this error?