Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add primary key to table with Macro

Status
Not open for further replies.

Poduska

Technical User
Dec 3, 2002
108
US
I once had a solution a long time ago see thread701-1164476 but we have upgraded from 97 to 2003 and I don't know why this will not work. I am assuming operator error but here goes.

I have a table created via make table query. I need to add a 2 field primary key to speed things up later.

Table = tbl_rpt_5_cc_inv
Two fields for key = "cus_num" and "Class_code"

I have tried both of these and always get the error
Invalid field definition "cus_num" in definition of index or relationship even though the field exists in the table

I have attempted to run each of the below statements using "RUNSQL" from the same macro which creates the table with the same error.

CREATE UNIQUE INDEX PrimaryKey ON tbl_rpt_5_cc_inv (cus_num) WITH PRIMARY

ALTER TABLE tbl_rpt_5_cc_inv ADD CONSTRAINT ConstraintName PRIMARY KEY (cus_num, class_code)


If further clarification is necessary please let me know.

Thanks for any help.
 
Is it possible that a caption has been set in table design for this field?
 
I checked anyway but there should be no caption as the table is recreated each macro execution via make table query.

Thanks
 
It may be worth trying this with a test table with two simple fields, Field1 and Field2, to check if this is a problem with this particular table or with all tables.
 
I tried the the simple Table1, Field1 and Field2 in a new database and low and behold it works perfect.

I scoured the macro again and "hang my head in shame" I did misspell the table name :(. I looked and looked at it....

Sorry for everyones time but thanks anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top