Calculating Primary Key Field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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.
 
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?
 
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.
 

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

Back
Top