Update query from 2 tables

geospatial

Active Member
Joined
Sep 2, 2008
Messages
290
Access 2013
Windows 10

I have 2 tables (Prsnl, dataImport)

In Prsnl I have 2 fields (fullName,EDIPI)
In dataImport I have 2 fields(Name,EDIPI)

The EDIPI field in Prsnl is blank, and I want to fill it with the values from dataImport.EDIPI

The query I tried was

UPDATE Prsnl
SET Prsnl.EDIPI = dataImport.EDIPI
WHERE Prsnl.fullName = dataImport.Name

When I try and run it I get it asking to update 0 rows.

I also try and do a SELECT as follows

SELECT * FROM Prsnl
WHERE Prsnl.fullName = dataImport.Name

I get 0 results on that as well, but when I compare the 2 it looks the same. Prsnl.fullName is a calculated field (not sure if that would cause the issue and if so, How should I go about fixing that)
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
A couple of points:

Generally calculated fields are a bad idea - unnecessary and can cause problems, however can be joined on so don't think this is the issue, although depends what the calculation is... I assume it is joining the forename to the surname?!

The word 'Name' is a reserved word and shouldn't be used as a field name, in-fact access stops you using this - is this a linked table?

My guess is that one of the tables includes extra spaces, you can check this by using Trim in your join:

Code:
SELECT Prsnl.*
FROM DataImport INNER JOIN Prsnl ON Trim(DataImport.[Name]) = Trim(Prsnl.FullName)

The other thing it could be is that spaces in one of the tables might not be actual spaces... in which case you would need to find out what character it is and remove/replace them.
 
Last edited:
Upvote 0
Actually - It could just have been the construct of your query was wrong... your tables are not joined, does this work:

Code:
SELECT Prsnl.*
FROM DataImport INNER JOIN Prsnl ON DataImport.[Name] = Prsnl.FullName
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top