Unique Values

Ian Mac

MrExcel MVP
Joined
Feb 20, 2002
Messages
1,174
All,

I have a table of data:
Book1
ABCDEF
1PidDateOfRequestTimeOfRequestDateOfHolidayStartTimeEndTime
2607411404/02/200412:3227/02/200417:0022:00
3607411404/02/200412:3328/02/200417:0022:00
4607411404/02/200412:4327/02/200417:0022:00
5607411405/02/200417:4301/03/200417:0022:00
6607411405/02/200418:4302/03/200417:0022:00
7607345605/02/200419:4303/03/200417:0022:00
8607345605/02/200420:4304/03/200417:0022:00
9607345605/02/200421:4305/03/200417:0022:00
10607856405/02/200422:4303/03/200417:0022:00
11607856405/02/200423:4307/03/200417:0022:00
12607856405/02/200400:4308/03/200417:0022:00
13607856405/02/200401:4303/03/200417:0022:00
Sheet1


This is an Access table in real life.

Can I prevent multiple entries based on certain fields only.
The yellow and pink highlights are duplicate entries because of Pid and DateOfHoliday

These are the only to fields I would like to compare.

Any suggestions?

(And they gave me a an Advanced Access Cert, I ask you?! :confused: )

kind regards
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi Ian,

Can you set the PID and Holiday Date as your primary key? If what you posted is your entire table then it seems as though that would make a good 'natural' primary key and would also solve your duplication problem.
 
Upvote 0
dk said:
Hi Ian,

Can you set the PID and Holiday Date as your primary key? If what you posted is your entire table then it seems as though that would make a good 'natural' primary key and would also solve your duplication problem.

The Pid is the primary key of the tblEmployees
Where the Pid come from in a Combobox Query on this table tblHolidayReq

How Can I set it as a primary key in this table as the same person will ask for lots of holidays their Pid will be duplicated many times
Also the holiday date because each person can request the same day.

Unless I've got it wrong??

Regards
 
Upvote 0
Ian,

Are you a night owl or an early riser? :)

You can set a composite primary key so that the combination of PID and Holiday Date must be unique for each record. In table design view select BOTH the PID and the Holiday date and click the primary key button. You will be able to enter a PID multiple times and a holiday date multiple times but you could only enter a specific date once for each employee.
 
Upvote 0
You can also set up multiple indexes as unique indexes.
In table design select >View>Indexes

The dialouge box that pops up allows you to set the indexes for the table. You can start a new one by adding a name under the index name column, then select the field names that you want to index together. at the bottom of the box you have the option to set the index as unique.

This has the advantage over a compound key because when you work in queries you have a single keyfield to join queries together with rather than remebering to connect all of the ones used to make the compound key.

Hope that makes sense :)

Peter
 
Upvote 0

Forum statistics

Threads
1,221,618
Messages
6,160,873
Members
451,674
Latest member
TJPsmt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top