Update Multiple Tables with Form Fields (1 Viewer)

jlfvlf

New member
Local time
Today, 08:27
Joined
Sep 4, 2019
Messages
8
After creating all the DIM statements and setting the statement to the correct field, I type:

DoCmd.RunSQL ("INSERT INTO tableA (Field1,Field2) VALUES (""" & iField1 & """),(""" & iField1 & """)")
DoCmd.RunSQL ("INSERT INTO tableB (Field3,Field4) VALUES (""" & iField3 & """),(""" & iField4 & """)")
DoCmd.RunSQL ("INSERT INTO tableC (Field5,Field6) VALUES (""" & iField5 & """),(""" & iField6 & """)")

But when I click the submit button, I get the following:

Run-time error '3346'

Number of query values and destination fields are not the same.

Am I missing a statement between the DoCmd.RunSQL statements?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:27
Joined
Oct 29, 2018
Messages
21,467
Hi. A good idea is to store the SQL statement into a String variable and examine its contents to make sure you are getting what you're expecting.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:27
Joined
May 7, 2009
Messages
19,230
DoCmd.RunSQL "INSERT INTO tableA (Field1,Field2) SELECT " & iField1 & "," & iField1
DoCmd.RunSQL "INSERT INTO tableB (Field3,Field4) SELECT " & iField3 & "," & iField4
DoCmd.RunSQL "INSERT INTO tableC (Field5,Field6) SELECT " & iField5 & "," & iField6
 

Users who are viewing this thread

Top Bottom