Rico wrote:
Hello,
I have a relationship that I'd like to modify using DAO. Right now the
Cascading updates are off, but I'd like to add them and I'm not sure the
best way to do that.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
A relationship is really a Foreign Key constraint (FK) between 2 tables.
You can use DDL (Data Definition Language) to define the FK. If the
relationship is already in force you'll have to drop it before you can
assign the new relationship, like this:
ALTER TABLE <foreign key table> DROP CONSTRAINT <constraint name>
If you created the relationship using the Relationship window the
constraint's name will be an internally produced serial number, or a
human readable name. This name is stored in the table
MSysRelationships, column szRelationship.
To create the new constraint use a statement like this:
ALTER TABLE <foreign key table> ADD CONSTRAINT FK_table_name
FOREIGN KEY (<fk column list>)
REFERENCES <primary key table> (<pk column list>)
ON UPDATE CASCADE
The <foreign key table> is the table on the the "many" side of the
relationship. The <primary key table> is the table on the "one" side of
the relationship. The <fk column list> is a comma-separated list of
columns that are in the foreign key table that relate to the <pk column
list> in the primary key table.
An example:
ALTER TABLE OrderDetails ADD CONSTRAINT FK_OrderDetails
FOREIGN KEY (invoice_nbr, order_nbr)
REFERENCES Orders (invoice_nbr, order_nbr)
ON UPDATE CASCADE
The column list for each table must be in the same order. IOW, the
OrderDetails.invoice_nbr relates to the Orders.invoice_nbr and the
OrderDetails.order_nbr relates to the Orders.order_nbr.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBRASmKIechKqOuFEgEQKdWQCgpfm8Ekmtsscv/w7DH2VBzWRhQooAn2P0
1hSwVVIRkfZztqWvUMuRb3fO
=sWa9
-----END PGP SIGNATURE-----