unclass123
unclass123

Reputation: 37

Microsoft Access - Integrity through relationships

I had a question about relationships in Access 2010. I have 2 tables:

Table 1       Table 2

ID Name       ID Name
1  George     1
2  Linda      2
3  Frank      3

Where I purposely left name in table 2 blank because I want to enforce a relationship between name in table 1 and name in table 2 with referential integrity. Currently if I enter a name into table 2 that is not in table 1 it does not catch it as an error. I want there to be data validation and I thought relationships was the way to do that. Am I understanding referential integrity wrong?

Upvotes: 0

Views: 38

Answers (1)

Lajos Arpad
Lajos Arpad

Reputation: 76508

You can enforce consistency via Data Macros, introduced since 2010. You need the following:

  • a data macro that RaiseError when an item is inserted/updated in table2 which does not have a match in table1
  • a data macro that handles table2 references when a given record from table1 is removed

However, this seems unintuitive. You could have a foreign key in table2 referring table1's id.

Upvotes: 1

Related Questions