Combining two fields question

J

JustMe

Not sure which group to place this question in.
Excuse my Duh...

I have a table whish has 2 text fields. I want to combine these
fields to make a unique ID field. Could someone explain please how I would
proceed with this?
Also, should I want to make this the key field?

Field1 = LName
Field2 = 4 digit number

Again both are text fields.

Thanks
 
E

Ed Robichaud

Every table should have a Primary Key and an autonumber field works best for
most applications. I recommend against using the sort of combo you suggest
as your primary key, as it will eventually fail (with thousands of records)
and will run slower than a numeric one field index.

That said, you can have many unique indices in a table, and you can have
multiple fields in any one index. Click on "View"-"Indexes" to get the
index dialogue box. Here you can build indexes, choose the unique property,
and select many fields to build that index.

-Ed
 
J

Just U

Add Field3 to your table to hold the combined results.

Create an update query based on table with both original
fields with the update option for Field3 is
tblYourTable!Field1 & tblYourTable!Field2

That should do it.
 
E

Ed Robichaud

Sorry, but that advice would be bad programming on two counts. 1) storing a
calculated result in the table (how would you handle updates/deletes of the
underlying fields?) and using a pseudo unique text field for a primary key
(they almost always fail with enough records - even SSN have to be repeated
every few generations!).
-Ed
 
Top