Deleting Duplicate Values in Linked Tables

ChuckRobert

Board Regular
Joined
Feb 26, 2009
Messages
64
I created an 2010 Access database to manage personnel data. One form is used to enter new personnel. On this form, a field called "Ind_Ser" (Individual_Serial_Number) is entered as this is a unique number given in our organization (primary key), writing to the Personnel table.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
Another field on this form called "Ratee_Ser" (Ratee_Serial_Number), (which is also the same number as the Individual_Serial_Number) is a hidden field, writing to the Rater/Ratee table. These tables are linked 1 to 1 with enforced referential integrity based on these values.
<o:p></o:p>
I created a process to check to see if the Individual_Serial_Number was already entered in the database, before trying to add an individual. After the Individual_Serial_Number is entered (and the number also transfers into the Rater/Ratee table, since it is linked), DCount checks the personnel table for duplicates and notifies by MsgBox before clearing the Individual_Serial_Number from the form. However, I can’t get it to clear the Ratee_Serial_Number by assigning a value of "", as both of these are required entries. I get an error message that states ‘The value violates the validation rule for the field or record’.

Can anyone offer a suggestion?

HTML:
Private Sub Ind_Ser_BeforeUpdate(Cancel As Integer)
 
Dim Criteria As String
Criteria = "[Ind_Ser]='" & Me.[Ind_Ser] & "'"
 
If DCount("*", "[tbl_Personnel]", Criteria) > 0 Then
    MsgBox "Serial Number " & Me.Ind_Ser & " already exists in this database.", vbOKOnly, "Duplicate Entry"
 
    Me.Ind_Ser.Text = ""
    Me.Ind_Ser.SetFocus
    
End If
 
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top