In the sample set-up illustrated, it is quite possible to edit a null to an existing element and to create records with nulls. I suspect you may have something not quite set correctly.
MS Access with referential integrity not allowing NULL values
-
16-01-2022 - |
Question
There are two tables in a Microsoft Access database. One of them defines elements, the other one references them. This reference is however optional. The value can be NULL. As long as the foreign key exists, I am not allowed to insert or update the NULL value. After saving the NULL value without the foreign key, I cannot add the key.
The reference column is set to "Required = false" and NULL values are allowed on its own. Only the referential integrity cannot handle NULL values.
How can that be solved?
Update: Something possibly relevant came to my mind: My foreign key uses two columns. One of them is always set but the other can be null.
Added sample schema:
Table bus:
Columns:
• objid integer
• busnumber integer
• name varchar
Primary key: objid, busnumber
Table conn:
Columns:
• objid integer
• name varchar
• bus1 integer
• bus2 integer
Primary key: objid, name
conn (objid, bus1) is referencing to bus (objid, busnumber) as 1:n and
conn (objid, bus2) is referencing to bus (objid, busnumber) as 1:n
Both references are optional, but objid is part of a superior object and is always set.
Solution