Prevention of Duplicate Records 359
LISTING 17.1
Fragment of Generated Code for Detection of Duplicate Records
' Section 4: Check for Duplicate Records
' Check for duplicates in Table Investment
' —INV_INVESTMENT_S
' Primary Key Column: Investment ID (INV_C)
strSQL = "SELECT * FROM INV_INVESTMENT_S WHERE INV_C = '" &
frmMe.INV_C & "'"
If Not IsNull(frmMe.RECORD_ID_C) Then
strSQL = strSQL & " AND RECORD_ID_C <> " &
CStr(frmMe.RECORD_ID_C)
End If
rstSource.Open strSQL, CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic, adCmdText
If Not rstSource.EOF Then
intErr = intErr + 1
strErr = "A record already exists for this Investment ID
(Error Code: R0052)"
End If
rstSource.Close
' Check for duplicates in Table Investment
' —INV_INVESTMENT_S
' Primary Key Column: ...