variable value not carrying through

W

Walter

I have the following code in the on click event of a command button. I have
some issues with quotes and in trying to get those worked out I discovered
that the variable "lngSVC" in the SQL shows no value although it does show a
value in the set value line. The variable "varTruck" shows the same value in
both places. As I presently have it I get an Error "Too few parameters.
expect 1". Why is the variable's value not showing?



Dim C As Control, lngSVC As Long, varTruck As Variant, strSQL As String

lngSVC = Me.Parent!Odometer (number field)
varTruck = Me.Parent!TruckID (text field)
strSQL = _
"UPDATE tblTrucks " & _
"SET tblTrucks.LastRoutineService = lngSVC " & _
"WHERE (((tblTrucks.TruckID) ='" & varTruck & "'" & "));"

For Each C ..........................................etc
 
J

Jeanette Cunningham

Hi Walter,

try it like this-->

strSQL = _
"UPDATE tblTrucks " & _
"SET tblTrucks.LastRoutineService = " & lngSVC & " " _
"WHERE tblTrucks.TruckID = """ & varTruck & """"
Debug.Print strSQL


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
W

Walter

Thanks so much! The space between the quotes was one thing I hadn't tried.
--
Thanks for your help!
Walter


Jeanette Cunningham said:
Hi Walter,

try it like this-->

strSQL = _
"UPDATE tblTrucks " & _
"SET tblTrucks.LastRoutineService = " & lngSVC & " " _
"WHERE tblTrucks.TruckID = """ & varTruck & """"
Debug.Print strSQL


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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