Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing Duplicate records with a relationship linkage

Status
Not open for further replies.

dean20

Technical User
Mar 27, 2000
6
US
Hello, here is the problem...<br><br>I have two tables (field A table1, field B table2), each with a 1:n to a third table (table3).<br>The third table can hold duplicate records of field A and field b,&nbsp;&nbsp;BUT&nbsp;&nbsp;the two fields together must be unique.<br><br>ex: field a&nbsp;&nbsp;4<br>&nbsp;&nbsp;&nbsp;&nbsp;fieldb&nbsp;&nbsp;&nbsp;6<br><br>cannot have&nbsp;&nbsp;a duplicate <br>&nbsp;&nbsp;&nbsp;&nbsp;field a&nbsp;&nbsp;4<br>&nbsp;&nbsp;&nbsp;&nbsp;field b&nbsp;&nbsp;6<br><br>CAN have<br>&nbsp;&nbsp;&nbsp;&nbsp;field a 4<br>&nbsp;&nbsp;&nbsp;&nbsp;field b 5<br><br>How do I prevent duplicates of combining both records in the third table?<br><br>I hope this is a clear question<br>Thanks in advance! :)
 
You can use the combined field as a primary key, or if you are using an Autonumber for a primary key, you can set up a unique index like this:<br><br>Set up a unique index on the two fields. Go into design mode of your table. Then click on the &quot;Indexes&quot; icon on the toolbar. Go to the first blank line in the Indexes Window. Enter a name (make one up) in the first column.Below this you will see 3 properties listed. Click on Unique and choose Yes. Go back to the second column of the line you were on and select the field you want to sort on first. In the third column select Ascending. On the next line, leave the name column blank (this means you are continuing with the name entered on the line above). In the second column enter the second field, and then choose Ascending for the third colum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top