Adding Constraints with Cascade

  • Thread starter Thread starter CurryMan
  • Start date Start date
C

CurryMan

I'm trying to add foreign key constraints to a table and everything
works
except that if I include the CASCADE ON DELETE/UPDATE options I get
errors.
Has any one got any ideas what I need to do or what could be wrong.

Cheers
Glenn


DoCmd.RunSQL "CREATE TABLE COLTBL (COLID COUNTER CONSTRAINT PrimaryKey
PRIMARY KEY, .... )", False

DoCmd.RunSQL "CREATE TABLE MAINTAB (....., COLID long ,.....)",False

DoCmd.RunSQL "ALTER TABLE MAINTAB ADD CONSTRAINT Constr1 FOREIGN KEY
(COLID) REFERENCES COLTBL"
***This works fine without ON UPDATE/DELETE Clause


DoCmd.RunSQL "ALTER TABLE MAINTAB ADD CONSTRAINT Constr1 FOREIGN KEY
(COLID) REFERENCES COLTBL ON UPDATE CASCADE ON DELETE CASCADE"
***But this comes up with and "Error in CONSTRAINT"
 
I'm trying to add foreign key constraints to a table and everything
works
except that if I include the CASCADE ON DELETE/UPDATE options I get
errors.

It depends how you are calling the SQL; different versions of jet allow
different clauses.

Try using ADO instead of DAO:

CurrentProject.Connection.Execute ...

HTH

Tim F
 
Back
Top