-1

I'm new to databases and I'm trying to run an update query whose pseudo code looks like the following: Update the last entry of TableA.ColumnA using the value in the last entry of TableB.ColumnB

I tried to do the following code:

UPDATE TableA
    SET TableA.ColumnA = (Select Last (ColumnB) from TableB )
    WHERE (((TableA.ColumnA)=(Select LAST(ColumnA) from TableA)));

But I get an error from Access that says "operation must use an updateable query".

I would appreciate any guidance or help.

Olivier De Meulder
  • 2,493
  • 3
  • 25
  • 30
VericalId
  • 105
  • 12

1 Answers1

0

Try to use MAX function

UPDATE TableA
    SET TableA.ColumnA = (Select MAX(ColumnB) from TableB )
    WHERE TableA.ColumnA = (Select MAX(ColumnA) from TableA);
Sherwin Obciana
  • 319
  • 1
  • 11
  • It gives me the same message. I tried to change the (Select MAX(ColumnB) from TableB ) for any number and it works but not when using the select query. – VericalId Nov 03 '17 at 02:15
  • Thank you for your help first of all. So if I try this UPDATE TableA SET TableA.ColumnA = 4 WHERE TableA.ColumnA = (Select MAX(ColumnA) from TableA); it will work or if I use my original attempt UPDATE TableA SET TableA.ColumnA = 4 WHERE (((TableA.ColumnA)=(Select LAST(ColumnA) from TableA))); It works but not when using the select query – VericalId Nov 03 '17 at 02:29
  • Did you try to change the permission of the folder? – Sherwin Obciana Nov 03 '17 at 02:49
  • No I have no idea how to do that. I'm a college student. Do you mean open the database as exclusive? – VericalId Nov 03 '17 at 03:04
  • You can visit this [link](https://stackoverflow.com/questions/19789709/operation-must-use-an-updateable-query-error-in-ms-access). Maybe it can give you some idea – Sherwin Obciana Nov 03 '17 at 03:14