Unquie records using two fields

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

I have a table with the fields Location1, Location2,
Distance and Time. I only use a entry in Location1 and
Location once.
Here is some example of vaild entries
Location 1 Location2
A B
A C
B A
but I can not now entry A to B again because it has
already been entered.
How do I set up my table so you can not entry duplicate
records?
thanks for your help
 
Tim,

In the design of the table, select Indexes from the View menu. Enter
something in the Index Name column, enter Yes in the Unique property
box, and put your Location1 and Location2 fields in the Field Name
column, one under the other. Hope that makes sense... if not, when you
have your cursor in the Index window, press the F1 key! The objective
is to define a unique index on the combination of the two Location fields.
 
In table design view, select both fields - hold the <Ctrl> key down - then
create an index on the selection. Make the index unique.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
When entering design View on you Table,a list of field names will appear
Just to the left of them is a grey block.Click on the first grey block,hold down CTRL key and click on the 2nd grey block
Now,at the top of you screen is a image of a Key,which refers to a Primary Key.CLick on it and save your table...
 
xxx said:
When entering design View on you Table,a list of field names will appear.
Just to the left of them is a grey block.Click on the first grey
block,hold down CTRL key and click on the 2nd grey block.
Now,at the top of you screen is a image of a Key,which refers to a Primary
Key.CLick on it and save your table...

That's if you want the two fields to be the primary key. The OP asked how
to make a unique index. A primary key will have a unique index, but a
unique index isn't necessarily the primary key. You can only set this up in
the index dialog, as Steve said.
 
Yes, you are correct, I was thinking of a Primary key. Your solution using
the Index dialog is the correct way.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Back
Top