Solved

access.mdb unique field

Posted on 2007-03-26
5
393 Views
Last Modified: 2012-08-14
Hello
I have an access.mdb table with three fields
ID Key autonum
supplierID number
StockID          number      
I want to combine supplierID and StockID in one and make it unique
Is this possible in access.mdb?
Regards
John
0
Comment
Question by:johnhardy
  • 2
  • 2
5 Comments
 
LVL 26

Expert Comment

by:jerryb30
ID: 18793259
You could create a composite index of the two fields, making them unique.  This would prevent the combo of the two from being added to the db.
0
 

Author Comment

by:johnhardy
ID: 18793370
Thanks
Can you please say how I create a composite field in access please?
0
 
LVL 13

Accepted Solution

by:
adraughn earned 300 total points
ID: 18793410
In table design, select both fields and then set primary key by selecting the key from the toolbat. This will prevent duplicates of records where both id's are identical.

If you need to show the combination of the fields in a query/form/report, just use this as an expression:

in access:
Expr1: [SupplierID] & [StockID]

in SQL:
[SupplierID] + [StockID] AS Expr1

-a
0
 
LVL 26

Assisted Solution

by:jerryb30
jerryb30 earned 200 total points
ID: 18793538
To create composite index, open table in design view.
Select View-Indexes, and give index a name. In the fields column, out in the two vields, i below the other, that you want to be unique.
Then, click in index name column. In index properties options, set Unique = yes.
Save your table.
Note, if you have two records with same supplierID and stockID, you will have to get rid of dupes before doing this process.
0
 

Author Comment

by:johnhardy
ID: 18793739
Many thanks for the answers.

Very helpful
Regards
John
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question