Microsoft Access Query To Build Relationship

MadSeb

New member
Local time
Today, 11:40
Joined
Jun 9, 2010
Messages
4
Hi,
I have the following table:



Table Parents with columns ID and FullName. ID is a primary key of type Auto-Number. Table Children with columns ID, ParentID and FullName. ID is a primary key of type Auto-Number. ParentID is of type Number.



I want to use the following query to build a "cascade deletion" so that when a parent is deleted all its children are automatically deleted.


I put the following Query in Access:


ALTER TABLE CHILDREN ADD CONSTRAINT ConstraintName FOREIGN KEY (PARENTID) REFERENCES PARENTS(ID) ON DELETE CASCADE


However, it doesn't work. I get the following error message: "Syntax Error in Constraint Clause" and the "DELETE" word get highlighted.


Any help would be greatly appreciated.


Regards, Seb
 
Why not just set the relationship to cascade delete related records? Much easier
 
Why not just set the relationship to cascade delete related records? Much easier

Hi,
Thanks for the reply...
I am building an upgrader for an application that uses an older access database....I am connecting to the access database from my C# app and executing a bunch of SQL statements to upgrade the database .....the statement in discussion is one of these statements...does that make sense ?
 
Oh I see.... I'll be of absolutely no help here then, sorry!
 

Users who are viewing this thread

Back
Top Bottom