Solved

access.mdb unique field

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now