Hi ..
I have a few text boxes on my form that I would like to check for duplicates before adding a record.. I managed to cobble the code below togther but think there is a problem in my sql... can anyone suggest a possible solution
I have a few text boxes on my form that I would like to check for duplicates before adding a record.. I managed to cobble the code below togther but think there is a problem in my sql... can anyone suggest a possible solution
Code:
Dim Rst As Recordset
Dim S As String
S = Me![ID] & Me![BR] & Me![JO] & Me![CO] & Me![SI]
Set Rst = CurrentDb.OpenRecordset("SELECT [ID] & [BRANCH] & [JOB TYPE] & [SITE LOCATION] AS T FROM JobSpec WHERE ((([ID] & [BRANCH] & [JOB TYPE] & [SITE LOCATION])='" & S & "'));", dbOpenDynaset)
If Rst.RecordCount <> 0 Then
MsgBox "Duplicates Found"
Cancel = True
End If
'CLEAN UP MEMORY AT END
If Not Rst Is Nothing Then
Rst.Close
Set Rst = Nothing
End If
End Sub