Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

access.mdb unique field

Posted on 2007-03-26
5
Medium Priority
?
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1200 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 800 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

Technology Partners: 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

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…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

609 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