No. of query values adn destination fields is not the same...

MarkusMD

New Member
Joined
Aug 30, 2017
Messages
3
Hi guys,

having trubble importing data in to a query.

I want to import all data att the same time to the same row but the code tells me that the number of varibles don't match the number of destinations. (Run-Time ERROR 3346)

What I have is this:

Code:
sub import()

lastID = DMax("ID", "MTQ1")

LV2 = "70"
LV3 = "69"
LV4 = "71"
LV5 = "25"
LV6 = "26"
LV7 = "25"
' These values are imported from an XML which makes them come out as strings

            sqls = "INSERT INTO MTQ1 (ID, LW1, LW2, LW3, LD1, LD2, LD3) VALUES ('" & lastID + 1 & ", " & LV2 & ", " & LV3 & ", " & LV4 & ", " & LV5 & ", " & LV6 & ", " & LV7 & " ') "
            
            Debug.Print sqls
            
            DoCmd.RunSQL sqls

End sub


Table looks as follows:

IDLW1LW2LW3LD1LD2LD3
1

<tbody>
</tbody>

Any ide where I go wrong?

Best Regards
MarksuMD
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
The problem is that you've defined all of the values as one by enclosing them in single quotes. Remove the two single quotes and it should work fine.
 
Upvote 0

Forum statistics

Threads
1,221,674
Messages
6,161,215
Members
451,691
Latest member
fjaimes042510

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