I am attempting to create a new primary key for an existing table, but when I attempt to compile the object I get “The Key already exists.” “The fields from the primary key are automatically appended to all secondary keys.” I want the new primary key to include a new field that I added to the table. **OLD Keys:**Job No.,Task Code,Phase Code Job No.,Phase Code I want the new keys to be: Job No.,Phase Code,Task Code,Billing Type Code Job No.,Task Code,Phase Code Job No.,Phase Code What could I be overlooking? Communication is the key !!!
You don’t need the key: Job No., Phase Code because it is equal to the start part (first 2 fields) of primary key. By the way, it’s not a good idea to change a primary key, unless it is a custom table and you know what you are doing [^]
Thanks, It worked like a charm. Yeah, this is a custom table… and obviously I’m not sure what I’m doing or what I’ve gotten into just yet. Time will Tell. By changing the primary key am I going potentially impact other objects that reference that table? What should I be checking or looking out for?
if there are objects doing get on that table you have to change the parameters of the get in according to the new primary key. Also you have to be sure that there will not be multiple records with the same values in the fields in primary key, but in this case you will have no problem since the new PK contains same fields of the previous one with an additional field.
Tony, is this a table that YOU peronally created? If not, you really need to be very carefull. If this is a development system, all may be fine, but if you are making changes to a live system, youculd be opening a huge can of worms. By adding a new field to the primary key, its is most likely that all existing code will continue to work. That is will not cause run time errors. BUT it is almost certain that the code will no longer correctly function. Reports are going to be out of whack, since multiple records will apear where there should only be one. At the least you are going to need to search for every piece of code that uses this table, and redesign the functionality. This is not a small task.