syntax error in insert into statement in vba

iamsvs

New Member
Joined
Dec 16, 2008
Messages
1
Hi

i got a error while insert a data. if same query i run in ms access its working row append.

but code through means its show error. pls help us.

Coding

Public db As New ADODB.Connection
.....
.....

vquery1 = "INSERT INTO DCD (PROD,TYPE,MONTH,AGEINGBRACKET,OCREF,PARTYNAME,INVQTY,FREIGHT,CFEXPENSES,COMMISSION) VALUES ('" & VPROD & "','" & VTYPE & "','" & VMONTH & "','" & VAGEINGBRACKET & "','" & VOCREF & "','" & VPARTYNAME & "'," & VINVQTY & "," & vpassvalue & ")"

db.Execute vquery1

query with values:

INSERT INTO DCD (PROD,TYPE,MONTH,AGEINGBRACKET,OCREF,PARTYNAME,INVQTY,FREIGHT,CFEXPENSES,COMMISSION) VALUES ('AV','1.BOOKED','2011 10 OCTOBER','6 - 9 Months','1/A/01','HAJI NOOR',20.344,0,0,0)

advanced thanks
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
hi

the Query with variables formula results in

INSERT INTO DCD (PROD,TYPE,MONTH,AGEINGBRACKET,OCREF,PARTYNAME,INVQTY,FREIGHT,CFEXPENSES,COMMISSION) VALUES ('string','string','string','string','string','string',numeric,numeric)
(this has 6 string values and 2 numeric values)

your 2nd example with values shows 6 string values and 4 numeric values

the insert is expecting 6 strings and 4 numerics so do you need to add cfexpense an commision variables to the first formula ?
 
Upvote 0

Forum statistics

Threads
1,215,232
Messages
6,123,759
Members
449,120
Latest member
Aa2

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