S
Sandy Burgess
Back again. This time I am having problems with an input form for new
patients. The form can not access existing patients. Similar problem as
previous post. Form should not allow duplicate SSN's
Table called Patient Data contains SSN (text field). There also is a field
call ID that is numeric. I have the following event procedure coded to the
before update .
Private Sub textSSN_BeforeUpdate(Cancel As Integer)
Dim strCriteria As String
strCriteria = "[SSN] = '" & Me.textSSN & "' AND " _
& "[ID] <> " & Me.textID
If IsNull(DLookup("SSN", "Patient Data", strCriteria)) Then
'do nothing, no match
Else
MsgBox "SSN exists. Verify SSN."
Cancel = True
Me.textSSN.SelStart = 0
Me.textSSN.SelLength = Len(Me.textSSN)
End If
End Sub
When a duplicate SSN is entered on the form I get the msg box with "SSN
exists. Verify SSN". When I hit ok. I get an Access Popup that states “The
value in the field or record violates the validation rule for the record or
field ………â€
How can I get rid this second popup? I got rid of the second popup on a
modify existing patient form with the above code but this code is not working
on the input form. Thanks for your help.
patients. The form can not access existing patients. Similar problem as
previous post. Form should not allow duplicate SSN's
Table called Patient Data contains SSN (text field). There also is a field
call ID that is numeric. I have the following event procedure coded to the
before update .
Private Sub textSSN_BeforeUpdate(Cancel As Integer)
Dim strCriteria As String
strCriteria = "[SSN] = '" & Me.textSSN & "' AND " _
& "[ID] <> " & Me.textID
If IsNull(DLookup("SSN", "Patient Data", strCriteria)) Then
'do nothing, no match
Else
MsgBox "SSN exists. Verify SSN."
Cancel = True
Me.textSSN.SelStart = 0
Me.textSSN.SelLength = Len(Me.textSSN)
End If
End Sub
When a duplicate SSN is entered on the form I get the msg box with "SSN
exists. Verify SSN". When I hit ok. I get an Access Popup that states “The
value in the field or record violates the validation rule for the record or
field ………â€
How can I get rid this second popup? I got rid of the second popup on a
modify existing patient form with the above code but this code is not working
on the input form. Thanks for your help.