concatenate two fields to generate primary key?

M

Matt D Francis

Hi,

Have looked for this in the forum but with no luck

I have two fields in a database

1) Form_No (example value "FT001")
2) Time_Of_Call (example "23:30")

There are several calls per form, so the table will have several rows for
FT001, but each with a different time.

What I want to do is to create a third field which will concatenate these
two to generate a key for that record i.e FT0012330

Is this possible? if so how? and will the second field being a Time/Date
format cause problems?
 
J

Jeff Boyce

Matt

Don't bother! If you already have two fields containing the data you need,
create a primary key spanning those two fields.

Good luck

Jeff Boyce
<Access MVP>
 
M

Matt D Francis

ah, I remember reading something about this, I'll give it a go - thank-you as
always

Matt
 
M

Matt D Francis

I managed to do this - but realised that I actually I wanted this extra field
to be a value I could use when joining to other tables - is that still
possible?
 
T

Tim Ferguson

I wanted this extra field
to be a value I could use when joining to other tables - is that still
possible?

Use two fields as the foreign key in the other tables too.

If you created this extra concatenated field in the first table, there is
simply no way to guarantee that it will always keep up to date with the
original two. What do you make of a record that is made up of:

"FT032", #13:37#, "TF0321336", ...?


All the best

Tim F
 
M

Matt D Francis

Okay, not quite sure what you meant about the keeping up to date bit, but
will have a crack at using the key across both fields. Thanks for your help,

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top