Reputation: 61
I am new to Access. So I have one Excel linked table in Access "Surge Arrester" which is unmodifiable and can only be modified in Excel. I want to copy the keys from the "Surge Arrester" in the field "ID/IDS" into a new table called "Surge Arrester internal" to the field, also called, "ID/IDS". I really don't understand how I can do this. Nothing I tried worked.
I tried this:
But nothing happens to the Surge Arrester Field internal ID/IDS field, it remains empty:
The data is there, in the Excel linked table.
Considerations:
-the data in the Surge Arrester is unmodifiable since it's a linked table.
-I want to use those keys to create a new table that I can do all sorts of stuff to, like appending other fields, etc.
-Chat gpt is dumb and can't tell me why is not working.
-I am a newbie in using access or any kind of databases.
-I used this tutorial, and everywhere I look I see the same method.
https://www.youtube.com/watch?v=iIberC3EpnE&t=153s
What is happening and why it's not working as intended?
Upvotes: -1
Views: 40
Reputation: 55981
First, as you do, link the Excel file.
Next, create a simple select query having the linked Excel table as source. In this query:
Save the query.
Finally, use this query as source in a combined update and append query, that will insert new records in your destination table and modify those (if any) that exist in the table. Here is how to build such a query:
Update and Append Records with One Query
Upvotes: 2
Reputation: 112672
Well, then you will have to do several things:
UPDATE [Surge Arrester internal] SAI
INNER JOIN [Surge Arrester] SA
ON SAI.[ID/IDS] = SA.[ID/IDS]
FROM
SET SAI.Caracteristic = SA.Caracteristica
INSERT INTO [Surge Arrester internal] ([ID/IDS], Caracteristic)
SELECT [ID/IDS], Caracteristica
FROM [Surge Arrester] SA
WHERE SA.[ID/IDS] NOT IN (SELECT [ID/IDS] FROM [Surge Arrester internal])
DELETE * FROM [Surge Arrester internal]
WHERE [ID/IDS] NOT IN (SELECT [ID/IDS] FROM [Surge Arrester])
Identifiers (table and column names) with spaces and special characters like "/" are not great when writing queries. They require you to put them in square brackets. The underline character "_" is a good replacement for these problematic characters.
Upvotes: 3