Solved

access.mdb unique field

Posted on 2007-03-26
5
377 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

776 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