Calculating Primary Key Field

S

Shaun

I have 2 fields, Building_No (Building number) and LocationID (Foreign key to
a location table). I want to use these 2 fields to create the primary key
field for Buildings such that it would be, "LocationID-Building_No". I know
I can do it with an update query, but I would rather not have it update all
1800+ records every time. Is there a way to have it update only the current
record either through an update query or macro? If need be, I can do the VBA
route, but would rather not get that messy. :) Thanks.
 
R

RoyVidar

Shaun said:
I have 2 fields, Building_No (Building number) and LocationID (Foreign key to
a location table). I want to use these 2 fields to create the primary key
field for Buildings such that it would be, "LocationID-Building_No". I know
I can do it with an update query, but I would rather not have it update all
1800+ records every time. Is there a way to have it update only the current
record either through an update query or macro? If need be, I can do the VBA
route, but would rather not get that messy. :) Thanks.

That's not the way to create a composite primary key. You just select
the two fields in the design view, then hit the primary key button.
 
S

Shaun

I know that now (the design was made before I did know), so unfortunately
everything has been structured with this primary key (including several VBA
programs). Any way of making this work the way it is or should I prepare for
all the rewrites?
 
K

KARL DEWEY

In a query field you can concatenate the two fields like this ---
LocationID-Building_No: [LocationID] & [Building_No]

How are you planning on using this compound field? You might have to re-do
everything.
 
Top