Question : How To Update Records With Joins

I am trying to use this SQL to populate a field in a table with data from a linked source.

UPDATE Transactions
LEFT JOIN Customers ON Transactions.BorrowerID = Customers.BorrowerID
SET Transactions.BorrowerName = Customers.BorrowerName

Straightforward enough, no?  Access says I need to use an "updateable query".  I have been researching this online and am getting the picture that the problem may be in the way I'm accessing data from the source, or in the structure of the target table.  Here are some clues:

1) "BorrowerID" is NOT unique in Transactions, so a select query should yield multiple rows for each ID.
2) "Customers" is actually a query on a linked table (source is CSV).
3) "BorrowerID" in Customers is a transformed version of BorrowerID in the real table.  It is only the rightmost 8 digits.

How can I get this update to work?

Mike

Answer : How To Update Records With Joins

Hi shacho

If a query includes a table of query that is not updateable, then the query will not be updateable.  In your case, the linked CSV is not updateable, so that stops your query from working.

It is one of the most annoying "features" of Access, but there are workarounds.  Here, I suggest you use a DLookup function to look up the BorrowerName corresponding to the BorrowerID:

UPDATE Transactions
SET BorrowerName = DLookup( "BorrowerName", "Customers", "BorrowerID=" & BorrowerID )

If Customers.BorrowerID is a text field then you will need to enclose the value in quotes:

DLookup( "BorrowerName", "Customers", "BorrowerID='" & BorrowerID & "'" )

Good luck!
--
Graham

Random Solutions  
 
programming4us programming4us