SQL Statement gives too few parameters - anything obvious?

  • Thread starter Thread starter Billp
  • Start date Start date
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.
 
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 &
""")"
 
Back
Top