How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Chris L. Your Own Question

Chris L.
Chris L., Support Specialist
Category: Microsoft Office
Satisfied Customers: 4835
Experience:  Certified Expert with over 10 years experience.
Type Your Microsoft Office Question Here...
Chris L. is online now
A new question is answered every 9 seconds

I have an Access database I created years ago. In order to

This answer was rated:

I have an Access database I created years ago. In order to improve it, I would like to establish some composite primary keys rather than continue using the existing primary key, which right now is an automatically generated number field. When I try to create the composite key, it says I need to remove some relationships that exist with other tables. I'm not sure what this would mean. I suspect I need to remove the existing primary key, but fear I would mess up my existing database by doing that. One example of some related tables I have are Invoice, Jobs and Vendors. When I enter data into an invoice form, I'd like a composite primary key that would include Job, Vendor, Invoice Number and Date. The Date and Invoice Number are a field in the Invoice table. The Job and Vendor are linked to the Job and Vendor tables. By establishing the composite primary key, I could have an invoice from a vendor that had items for more than one job on it, so I could have duplicates of the invoice number on invoice records, and a unique value in the job field would separate it.

I hope I'm being clear here. I'd appreciate any help you could give me.
Hello and thank you for using Just Answer.

I believe I understand what you are trying to do, it is a little difficult without actually seeing the database.

Before you start working with the instructions I am about to give, please make a backup/copy of your database.

You should perform the instructions on your copy of the database that way nothing accidentally goes wrong with you main database.

Again perform the following on a copy of your database.

Before you can remove a primary key, you must make sure that it doesn't participate in any table relationships. If you try to remove a primary key for which a relationship exist, Access warns you that you must delete the relationship first.

If the tables that participate in the table relationship are open, close them. You cannot delete a table relationship between open tables.
On the Database Tools tab, in the Show/Hide group, click Relationships.

If the tables that participate in the table relationship are not visible, on the Design tab, in the Relationships group, click Show Table. Then select the tables to add in the Show Table dialog box, click Add, and then click Close.

Click the table relationship line for the table relationship that you want to delete (the line appears bold when it is selected), and then press the DELETE key.
On the Design tab, in the Relationships group, click Close.

In the Navigation Pane, right-click the table from which you want to remove the primary key and then click Design View on the shortcut menu.
Select the current primary key field.

If the primary key consists of multiple fields, click the row selector for any field in the primary key.
On the Design tab, in the Tools group, click Primary Key.

The key indicator is removed from the field or fields that you previously specified as the primary key.

Please Note: When you save a new table without setting a primary key, Access prompts you to create one. If you choose Yes, an ID field is created that uses the AutoNumber data type to provide a unique value for each record. If your table already includes a AutoNumber field, Access uses that field as the primary key.

Select the field or fields that you want to use as the primary key.
To select more than one field, hold down CTRL while you click the fields.

On the Design tab, in the Tools group, click Primary Key.
A key indicator appears to the left of the field or fields that you specify as the primary key.

Press CTRL+S to save your table design changes.

If this does not help or is not what you are looking for please reply and let me know, otherwise please click the accept button.

Thank You
Customer: replied 4 years ago.
I understand your instructions. What I'm not sure of is whether or not the relationships between tables will re-establish themselves using the new composite primary key after I set them up. I would like to be able to query the database and have access to all the records I've entered under the old primary key.
You will need to reestablish the relationships/querys after changing the primary key. Im on a train right now so if you can give me a little time I will respond further.
Thanks I will be back online in a few hours
Ok I thought about this a bit more.

What I would suggest you try on your testing(copy) of the database if to either, remove the relationships and try and create the composite keys In table design mode, select first key field, hold the control key and select the second key field etc... With fields selected, click the key icon to add a key.

Hope this helps.
Chris L. and other Microsoft Office Specialists are ready to help you
Customer: replied 4 years ago.

I will try your suggestion. It may take me a day or so as I'm busy right now, but I'll get back to you as soon as I determine if this works.



No problem take your time and good luck.
Customer: replied 4 years ago.

I'm sorry it's taken me a while to follow through on this issue. Turns out it is more involved than just manipulating relationships and keys. I have some blank fields in a lot of the records that already exist and before I can set those fields as primary keys, I need to either delete those records or fill those fields. So, I have some work to do before I can fully deploy the fix. However, I believe I'm on the right track and will accept your answer and then probably get back to you for more guidance.