I am needing to check for duplicates where the field values will sometimes have apostrophes or null values. The code below works for apostrophes but I get an "Invalid use of Null" error if one of the fields is Null, but I still need it to check for duplicates because not all fields are required. The only fields that are required are txtSongData and grpChoirEnsemble.
If DCount("*", "tblSongData", "[SongTitle] = '" & Replace(Me.txtSongTitle, "'", "''") & "'" & " AND [BookTitle] = '" & Replace(Me.BookTitle, "'", "''") & "'" & " AND [Artist] = '" _
& Replace(Me.cmbArtist, "'", "''") & "'" & " AND [ChoirEnsemble] = " & Me.grpChoirEnsemble) > 0 Then
Msg = "This song already exist with this book title and artist for the " & strChoirEnsemble & "."
Style = vbOKOnly + vbExclamation
Response = MsgBox(Msg, Style, Title)
Me.Undo
Cancel = True
End If
Please advise.
Thank you,
John