Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim lngNoRecords as Long, strSql as string
'This checks for duplicates before saving a new record
If me.NewRecord then
' In this example Field1 is a string, Field2 is a number
strSql = "Field1 = '" & Control1 & "' AND Field2 = " & Control2
' lngNoRecords should return 0 if no matching record exists or the number of matching records
lngNoRecords = DCount("*","yourTableName",strSql)
' Cancels update of record if one already exists
If lngNoRecords > 0 then
Cancel = TRUE
MsgBox "A record already exists"
End If
End If
End Sub