Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello,


i am using MS Access as back end. my table structure is
{ SId (number),
PId (number),
Qty (number)
}
i want make SId+ Pid as unique,i.e combination of this both key should not repeat.

i.e
1, 1, 5
1,2, 5
it should be accept.
but
1,1,5
1,1,12
should not accept

how should be this done?
Posted

It sounds to me that you want to create an intersect table for a Many-to-Many relationship. I know that in Access there is the possibility of checking for duplicates per column but not a combination of columns.

So if you want to do this you'd have to do it in code within your program or make a stored procedure within the Access database to avoid it from being added.
 
Share this answer
 
v2
You need to define primary key for that follow this steps

1. Open table in design view
2. Select both column Sid, Pid
3. rigth click on it, selct set primary


:)


Update 1

Have you assign primary key ?
by following above steps
there is no need to assign unique key

Thanks
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900