Hi Guys,
long time since i have been here (we moved to Excel entirely
)
i have 2 tables:
ID is a key for us.
t_AnimalInput
t_AnimalSource
and now expexted result is:
ResultTable
Sp User inputted something in t_AnimalInput table.
And i want to check if in t_AnimalSource there is a record which does not exists and if not, append to t_AnimalInputs.
So i have used this SQL:
which is working perfect.
But how to check if there is a still the same records in both tables and if they have the same keys - update them?
As you can see ID = 2 is different because Color changed from Black to White.
It is better to use second SQL somehow or VBA after first insert SQL?
I think that SQL solution is more desired. Because Access VBA <> Excel VBA and i can be force to use also these kind of operations in Excel in the future.
Please help,
thank you in advance
Jacek
long time since i have been here (we moved to Excel entirely

i have 2 tables:
ID is a key for us.
t_AnimalInput
ID | Animal | Color |
---|---|---|
1 | Dog | Green |
2 | Cat | White |
ID | Animal | Color |
---|---|---|
1 | Dog | Green |
2 | Cat | Black |
3 | Mouse | Red |
ResultTable
ID | Animal | Color |
---|---|---|
1 | Dog | Green |
2 | Cat | White |
3 | Mouse | Red |
And i want to check if in t_AnimalSource there is a record which does not exists and if not, append to t_AnimalInputs.
So i have used this SQL:
Code:
INSERT INTO t_AnimalInput ( ID, Animal, Color )
SELECT t_AnimalSource.ID, t_AnimalSource.Animal, t_AnimalSource.Color
FROM t_AnimalSource LEFT JOIN t_AnimalInput ON t_AnimalSource.ID = t_AnimalInput.ID
WHERE (((t_AnimalInput.ID) Is Null));
which is working perfect.
But how to check if there is a still the same records in both tables and if they have the same keys - update them?
As you can see ID = 2 is different because Color changed from Black to White.
It is better to use second SQL somehow or VBA after first insert SQL?
I think that SQL solution is more desired. Because Access VBA <> Excel VBA and i can be force to use also these kind of operations in Excel in the future.
Please help,
thank you in advance
Jacek