Listing Cascade Update / Delete Referential Integrity Rules in an MS-Access Database?
-
13-07-2021 - |
Question
In MS-Access I'm aware of referential integrity rules such as cascading updates and deletes and creating them using DDL.
But after the tables have already been created, how can these be listed again?
Solution
In VBA you can use TableDefs and Relations collections to show table and relationship properties. You can also use ADO Schemas to get information.
In particular, you will wish to refer to the attributes of the relationship:
Name Value Description
dbRelationDeleteCascade 4096 Deletions cascade
dbRelationDontEnforce 2 Relationship not enforced (no referential integrity)
dbRelationInherited 4 Relationship exists in the database containing the two linked tables
dbRelationLeft 16777216 Microsoft Access only. In Design view, display a LEFT JOIN as the default join type.
dbRelationRight 33554432 Microsoft Access only. In Design view, display a RIGHT JOIN as the default join type.
dbRelationUnique 1 One-to-one relationship
dbRelationUpdateCascade 256 Updates cascade
http://msdn.microsoft.com/en-us/library/bb225809.aspx
Dim rel As Relation
Dim tdf As TableDef
For Each rel In CurrentDb.Relations
Debug.Print rel.Attributes
Next
4352 = dbRelationUpdateCascade + dbRelationDeleteCascade
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow