update query between two tables (1 Viewer)

sab_db_12

Registered User.
Local time
Today, 12:47
Joined
Sep 3, 2012
Messages
11
Hi!
I posted a thread titled "beginner in vba - select query" some days ago.
I tried another way but there is another problem.

This is my problem. I would like to show 'field1' and 'field2' on form2, but 'field1' and 'field2' are saved in table1. moreover, I would like to save 'field1' and 'field2' in the table2, in the same record where I'm saving data I insert in form2.

well, the relation between tables is right.

this is my new query:


UPDATE table2 SET field1 = (SELECT table1.field1 FROM table1 WHERE table1.field3=table2.field3) SET field2 = (SELECT table1.field2 FROM table1 WHERE table1.field3=table2.field3);

A error is shown:

"Operation must use an updatable query."

Error: 2950.

Whyyyyyyyyy???????????
 

jdraw

Super Moderator
Staff member
Local time
Today, 06:47
Joined
Jan 23, 2006
Messages
15,394
This is invalid syntax
(SELECT table1.field1 FROM table1 WHERE table1.field3=table2.field3)

You only identify Table1, yet you are referencing a field in Table2
Same situation in your second SELECT.Also you have to SET commands which is a syntax error.

Try
Code:
UPDATE  Table1 INNER JOIN Table2 ON
Table1.field3 = table2.field3
SET Table2.field1=Table1.field1
,Table2.field2 = Table1.field2;
 

sab_db_12

Registered User.
Local time
Today, 12:47
Joined
Sep 3, 2012
Messages
11
thank you so much!!!!
 

Users who are viewing this thread

Top Bottom