I am modifying the assets template in ACC 2007 and need to do the same check except I have 3 values that identify a duplicate record. I was able to concatenate the 3 values in txtbox uniqueidcheck for the current entry form, and then do a dlookup of the database in txtbox query_unique. I'm also using the dlookup to bring the ID (Primarykey) into another txtbox called IDLookup.
What I want to do is:
1) After they enter the third value, it checks for duplicates.
2) Prompt to change to the existing record and refresh the whole form from the existing record.
Private Sub Condition_AfterUpdate()
Dim intResponse As Integer
Dim stlinkcriteria As String
Dim QID As Integer
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
stlinkcriteria = "[ID]=" & QID
On Error GoTo Err_Handler
Forms![asset details]!Query_Unique.Requery
Forms![asset details]!IDLookup.Requery
QID = Forms![asset details]!IDLookup
If Forms![asset details]!Query_Unique = Forms![asset details]! UniqueIDCheck Then
intResponse = MsgBox("The RMA, Condition and Item already exists." & Chr(13) & "Do you want to switch to the other record?", vbQuestion + vbYesNo)
If intRespose = vbYes Then
DoCmd.SetWarnings False
Me.Undo
rsc.FindFirst stlinkcriteria
Me.Bookmark = rsc.Bookmark
'rsc.SearchForRecord , , acFirst, "[RMA Number] =" & Forms![asset details]!Manufacturer & "AND Condition =" & _
Forms![asset details]!Condition & "AND ITEM=" & Forms![asset details]!Item
DoCmd.SetWarnings True
End If
Set rsc = Nothing
End If
Exit Sub
Err_Handler:
MsgBox Err.Description
Exit Sub
End Sub