My Table “Cast” has these fields:
cID (PK), cFName, cMName and cLName
The form I am using to update this table is called fCast.
I would like to prevent entering same name twice. I have used the following code to prevent entering same Title twice which is working. But I am not sure how to concatenate 3 name fields and apply similar codes. Can someone please help?
My code to prevent duplicating a title
Private Sub iTitle_AfterUpdate()
Dim iTitle As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
iTitle = Me.iTitle.Value
stLinkCriteria = "[iTitle]=" & "'" & Replace(Me![iTitle], "'", "''") & "'"
'Check Items table for duplicate iTitle
If DCount("iTitle", "Items", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Item Title " _
& iTitle & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original Title
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
cID (PK), cFName, cMName and cLName
The form I am using to update this table is called fCast.
I would like to prevent entering same name twice. I have used the following code to prevent entering same Title twice which is working. But I am not sure how to concatenate 3 name fields and apply similar codes. Can someone please help?
My code to prevent duplicating a title
Private Sub iTitle_AfterUpdate()
Dim iTitle As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
iTitle = Me.iTitle.Value
stLinkCriteria = "[iTitle]=" & "'" & Replace(Me![iTitle], "'", "''") & "'"
'Check Items table for duplicate iTitle
If DCount("iTitle", "Items", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Item Title " _
& iTitle & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original Title
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub