Warn But Not Prevent Duplicate Data

Silly me. Now I'm getting access can't find the field MVRRS_Learner_ID referred to in your expression, but the field name is exactly the same?

Post what you have exactly now again - as I said the essence of it now works fine. (i have it working here), and double check your field names, both table and form.
 
Post what you have exactly now again - as I said the essence of it now works fine. (i have it working here), and double check your field names, both table and form.

Private Sub NI_number_BeforeUpdate(Cancel As Integer)
Dim Answer As Variant
Answer = DLookup("[NI_number]", "LearnerDetails", "[NI_number] = '" & Me.NI_Number & "' AND [MVRRS_Learner_ID] <>" & Nz(Me!MVRRS_Learner_ID, 0))
If Not IsNull(Answer) Then
MsgBox "Duplicate National Number Found" & vbCrLf & "Please enter again.", vbCritical + vbOKOnly + vbDefaultButton1, "Duplicate"

Cancel = True

Else:
End If
End Sub

Sorry for being a pain!
 
Private Sub NI_number_BeforeUpdate(Cancel As Integer)
Dim Answer As Variant
Answer = DLookup("[NI_number]", "LearnerDetails", "[NI_number] = '" & Me.NI_Number & "' AND [MVRRS_Learner_ID] <>" & Nz(Me!MVRRS_Learner_ID, 0))
If Not IsNull(Answer) Then
MsgBox "Duplicate National Number Found" & vbCrLf & "Please enter again.", vbCritical + vbOKOnly + vbDefaultButton1, "Duplicate"

Cancel = True

Else:
End If
End Sub

Sorry for being a pain!


Is the field MVRRS_Learner_ID on te form as a text box?
 

Users who are viewing this thread

Back
Top Bottom