Hello,
I'm trying to trap error 3022, which occurs when you try to update a record with a duplicate value in an index. My code looks like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo DupWorkOrder
Exit_Form:
Exit Sub
DupWorkOrder:
If Err.Number = 3022 Then
MsgBox "DupError"
End If
End Sub
As you can see, I've placed it in the BeforeUpdate event, but when I step through the code with a definite duplicate, the code isn't recognizing the error and I get the standard Access error.
Should I be putting this code somewhere else?
Thanks,
Mike
I'm trying to trap error 3022, which occurs when you try to update a record with a duplicate value in an index. My code looks like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo DupWorkOrder
Exit_Form:
Exit Sub
DupWorkOrder:
If Err.Number = 3022 Then
MsgBox "DupError"
End If
End Sub
As you can see, I've placed it in the BeforeUpdate event, but when I step through the code with a definite duplicate, the code isn't recognizing the error and I get the standard Access error.
Should I be putting this code somewhere else?
Thanks,
Mike