A
Access
I have some tables whose records I gather using a union query as below:
Suppliers: ID, name
Customers: ID, name
Employees: ID, name
So the union query has two columns, ID and Name.
The necessity is to have a lookup in a table holding mail receipients, that
can be either out of the company (suppliers, customer) or internal
(employees) or both.
All lookups in other tables are made using the ID field. Here in the union
table the ID field is not unique, thus I can't enforce RI cause IDs in the
union come from different tables, so when using the union query as a lookup
on the receipients table, if I select a record that its source is different
than the first table in the union query, if a record in the second table has
an ID that the first table has, it shows the first's tables name.
eg.
Source ID Name
-----------------------------------
Customer 1 abc
customer 2 def
supplier 1 ajk
Supplier 2 mbl
Supplier 3 ikl
If I select 'abc', it correctly saves id=1 and displays 'abc'
if then in another record, I select 'ajk', it saves id=1 BUT displays 'abc'
instead of 'ajk'
If then I select 'ikl' it saves and displays correctly 'ikl'
The issue here is that I wan't to be able to select from the union query,
but in the same time have RI with each of the union query's tables to the
receipients table, so that if eg a customer has correspondance, it cannot be
deleted from the customers table.
Suppliers: ID, name
Customers: ID, name
Employees: ID, name
So the union query has two columns, ID and Name.
The necessity is to have a lookup in a table holding mail receipients, that
can be either out of the company (suppliers, customer) or internal
(employees) or both.
All lookups in other tables are made using the ID field. Here in the union
table the ID field is not unique, thus I can't enforce RI cause IDs in the
union come from different tables, so when using the union query as a lookup
on the receipients table, if I select a record that its source is different
than the first table in the union query, if a record in the second table has
an ID that the first table has, it shows the first's tables name.
eg.
Source ID Name
-----------------------------------
Customer 1 abc
customer 2 def
supplier 1 ajk
Supplier 2 mbl
Supplier 3 ikl
If I select 'abc', it correctly saves id=1 and displays 'abc'
if then in another record, I select 'ajk', it saves id=1 BUT displays 'abc'
instead of 'ajk'
If then I select 'ikl' it saves and displays correctly 'ikl'
The issue here is that I wan't to be able to select from the union query,
but in the same time have RI with each of the union query's tables to the
receipients table, so that if eg a customer has correspondance, it cannot be
deleted from the customers table.