View Single Post
  #2  
Old September 21st, 2004, 12:43 PM
Nikos Yannacopoulos
external usenet poster
 
Posts: n/a
Default

J.,

No need to use an extra field for concatenation, just open your table in
design view, select all three fields (by clicking on the little grey button
to the left of each field name while holding down Ctrl), and click on the
Primary Key tool button on the toolbar. This will create a composite PK that
will only allow unique combinations of the three field entries.

Note: this is an easy way to do it, but not necessarily the best design.
Ideally, you would use an autonumber PK field in tblPeople, which would make
joins to other tables much more efficient, and employ some other method to
avoid double entries, e.g. use a macro or some code in the Before Update
event of the data entry form to look for double entries. Alternartively, you
could stick with the composite PK on the three fields to prevent duplicates,
but still use an (indexed) autonumber field for joining with other tables.

HTH,
Nikos


"JBowler" wrote in message
...
Is it possible to make a combination of 3 fields be unique? I know you can
have the ID (autonumber) be unique or have a field set to be indexed and

not
allow duplicates but I need to use 3 fields.

My scenario is a table (tblPeople) with Fname, Lname and postcode. I do

not
want any duplicate people in my tblPeople. They all have multiple linked
records in tblProjects. The problem is that someone doing data entry keeps
creating duplicate people entries when they exist already. Can I set these

3
to be unique together? Not as individual uniques.

Would it be easier to make a field in the tblPeople that is a combination

of
Fname Lname Postcode and that be unique? Then on the form it would use

some
code to make the combination entered into that field. I could run a query

to
make the 3000+ records have that combination field so its all up to date.

What is my best approach? Any help or thoughts are appreciated. Many

thaks.

JBowler