I'm trying to get a duplicate entry into a textbox flagged as a before_update warning message. The field is "Hospital_Numbe r" within the table "Voc Rehab DB". The Hospital Number is a text field since hospital numbers can include things like: U/G39401
At the moment I have the following code:
Please help!
At the moment I have the following code:
Code:
Private Sub Hospital_Number_BeforeUpdate(Cancel As Integer)
If Nz(DCount("Hospital_Number", "Voc Rehab DB", "Hospital_Number = '" & Me.Hospital_Number.Text & "'"), 0) > 0 Then
If MsgBox("The value you are adding already exists do you wish to continue?", vbOKCancel, "Duplicate Warning") = vbCancel Then
Cancel = True
Me.Undo
Exit Sub
End If
End If
End Sub
Comment