mike60smart
Registered User.
- Local time
- Today, 23:25
- Joined
- Aug 6, 2017
- Messages
- 1,904
Hi Everyone
Where am I going wrong with the following Code?
The correct Message pops up and says there is a Duplicate.
I click the OK button and it closes the Form vice setting Focus to the Control.
Any help appreciated.
Where am I going wrong with the following Code?
The correct Message pops up and says there is a Duplicate.
I click the OK button and it closes the Form vice setting Focus to the Control.
Any help appreciated.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
10 On Error GoTo Form_BeforeUpdate_Error
20 If DCount("[MChip]", "tblDogs", "[MChip] = '" & Me.Mchip & "'") <> 0 Then
30 Me.Undo
40 MsgBox "This Microchip Nr already exists:-" & vbCrLf, vbOKOnly + vbExclamation
50 Exit Sub
60 End If
70 Me.CallName.SetFocus
80 On Error GoTo 0
90 Exit Sub
Form_BeforeUpdate_Error:
100 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_BeforeUpdate, line " & Erl & "."
End Sub