G
Gordon
I am using the code below in the before update of my form to check for
duplicate records (using the criteria surname/postcode/issue date less
than 2 years.
strSQL = "SELECT DISTINCTROW tblCompTicketIssues.fldSurname,
tblCompTicketIssues.fldPostCode, "
strSQL = strSQL & "FROM tblCompTicketIssues WHERE DateDiff(" & """d"""
& ",[fldIssueDate],Now()) < 730 AND "
strSQL = strSQL & "(((tblCompTicketIssues.fldSurname) In (SELECT
[fldSurname] FROM [tblCompTicketIssues] "
strSQL = strSQL & "As Tmp GROUP BY [fldSurname],[fldPostCode] HAVING
Count(*)>1 And [fldPostCode] = [tblCompTicketIssues].
[fldPostCode])))"
Set db = CurrentDb()
Set rst = db.OpenRecordset(strSQL)
With rst
' Loop through the records, creating a string of names and ID numbers
Do While Not .EOF
sOut = sOut & " " & !fldSurname & " " & !fldPostCode & " - Issue
ID # " & !fldContactID & vbCrLf
..MoveNext
lngDupes = lngDupes + 1
If lngDupes > conMaxDupes And Not .EOF Then
sOut = sOut & " and others." & vbCrLf
The code works OK, giving the user the opportunity on input/update to
accept a duplicate. The problem is that after the update of any
record, the message box throws up all the duplicates, even ones that
have been previously accepted. How can I modify the code so that it
just checks if the current record is a duplicate of any others.
Gordon
duplicate records (using the criteria surname/postcode/issue date less
than 2 years.
strSQL = "SELECT DISTINCTROW tblCompTicketIssues.fldSurname,
tblCompTicketIssues.fldPostCode, "
strSQL = strSQL & "FROM tblCompTicketIssues WHERE DateDiff(" & """d"""
& ",[fldIssueDate],Now()) < 730 AND "
strSQL = strSQL & "(((tblCompTicketIssues.fldSurname) In (SELECT
[fldSurname] FROM [tblCompTicketIssues] "
strSQL = strSQL & "As Tmp GROUP BY [fldSurname],[fldPostCode] HAVING
Count(*)>1 And [fldPostCode] = [tblCompTicketIssues].
[fldPostCode])))"
Set db = CurrentDb()
Set rst = db.OpenRecordset(strSQL)
With rst
' Loop through the records, creating a string of names and ID numbers
Do While Not .EOF
sOut = sOut & " " & !fldSurname & " " & !fldPostCode & " - Issue
ID # " & !fldContactID & vbCrLf
..MoveNext
lngDupes = lngDupes + 1
If lngDupes > conMaxDupes And Not .EOF Then
sOut = sOut & " and others." & vbCrLf
The code works OK, giving the user the opportunity on input/update to
accept a duplicate. The problem is that after the update of any
record, the message box throws up all the duplicates, even ones that
have been previously accepted. How can I modify the code so that it
just checks if the current record is a duplicate of any others.
Gordon