Duplicate finding in table

m9jiihmr@gmail.com

New member
Local time
Today, 05:14
Joined
Jun 11, 2013
Messages
13
Hello All

In a table, where participantid is set as primary key, in this table there are two more fields, Name and Organisation.

However, in a table , participantid takes a different value for a different records.

But my query is,

Even for a different participantid, I want to check, whether there is same Name and Organisation record exist in the table, if yes shows warning.

Example:


ParticipantId Name Organisation

23 M MNO

Now when user enters next record,
that is 24,
and by mistake he/she enters , again like
24 M MNO

So during record saving or moving to next record, there should show some warning,

Same record found, you want to accept it, with two options. Yes, No,

If Yes, Record saves in table, If No, then does not Save.

Please suggest.
Thanks and Regards
Manoj
 
I thought I already gave you a response??
Code:
Private Form_BeforeUpdate(Cancel As Integer)
    If DCount("*", "yourTable", "[Name] = '" & Me.NameTextBox & "' AND Organisation = '" & Me.OrganisationTxtBox & "') <> 0 Then
        If MsgBox("Another record with Name and Organization exists in the table." & vbCrLf & vbCrLf & _
                  "Continue with Save?", vbYesNo + vbQuestion) = vbNo Then Cancel = True
    End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom