SQL Statement gives too few parameters - anything obvious?

B

Billp

Hi

Dim value1 As String
Dim value2 As String
Dim value3 As String
Dim strsql_back As String


value1 = Nz(Me![TotalCost])
value2 = Nz(Me![Sale_Price])
value3 = Nz(Me!Works_Number)


strsql_back = "INSERT INTO [tblWCard_Information_Change]
([Cost_Total_Old],[Sell_Total_Old],[WCard_Number])" _
& " VALUES (" & value1 & "," & value2 & "," & value3 & ")"
Debug.Print strsql_back

DBEngine(0)(0).Execute strsql_back, dbFailOnError


Is there anything that stands out as wrong if
Value1 is numeric
Value2 is Numeric
Value 3 is text
That would give Too few parameters. expect 1.
 
M

Marshall Barton

Billp said:
Dim value1 As String
Dim value2 As String
Dim value3 As String
Dim strsql_back As String


value1 = Nz(Me![TotalCost])
value2 = Nz(Me![Sale_Price])
value3 = Nz(Me!Works_Number)


strsql_back = "INSERT INTO [tblWCard_Information_Change]
([Cost_Total_Old],[Sell_Total_Old],[WCard_Number])" _
& " VALUES (" & value1 & "," & value2 & "," & value3 & ")"
Debug.Print strsql_back

DBEngine(0)(0).Execute strsql_back, dbFailOnError


Is there anything that stands out as wrong if
Value1 is numeric
Value2 is Numeric
Value 3 is text


If value3 is text, then you should use:

& " VALUES (" & value1 & "," & value2 & ",""" & value3 &
""")"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top