Update query: Data type mismatch

D

David M C

Here's my code:

Do While currentDate <= tempFinish
strSQL = "UPDATE Forecast SET Forecast.totalValue = ""totalValue""
+" & dailyValue & " WHERE (((Forecast.calDate)=#" & Format(currentDate,
"mm/dd/yyyy") & "#));"
cmd.CommandText = strSQL
Debug.Print strSQL
cmd.Execute
currentDate = currentDate + 1
Loop

And here's the strSQL output in the immediate window:

UPDATE Forecast SET Forecast.totalValue = "totalValue" +263.4528 WHERE
(((Forecast.calDate)=#01/01/2006#));

However, I get a "data type mismatch in criteria expression" error. I don't
get this error if I remove the #'s, but none of the fields get updated. Any
ideas?

Thanks,

Dave
 
D

Duane Hookom

Try this:

Do While currentDate <= tempFinish
strSQL = "UPDATE Forecast " & _
"SET [totalValue] = [totalValue] + " & dailyValue & _
" WHERE [calDate]=#" & Format(currentDate, "mm/dd/yyyy") & "#"
cmd.CommandText = strSQL
Debug.Print strSQL
cmd.Execute
currentDate = currentDate + 1
Loop
 
D

David M C

Thanks, sorted.

Duane Hookom said:
Try this:

Do While currentDate <= tempFinish
strSQL = "UPDATE Forecast " & _
"SET [totalValue] = [totalValue] + " & dailyValue & _
" WHERE [calDate]=#" & Format(currentDate, "mm/dd/yyyy") & "#"
cmd.CommandText = strSQL
Debug.Print strSQL
cmd.Execute
currentDate = currentDate + 1
Loop

--
Duane Hookom
MS Access MVP

David M C said:
Here's my code:

Do While currentDate <= tempFinish
strSQL = "UPDATE Forecast SET Forecast.totalValue = ""totalValue""
+" & dailyValue & " WHERE (((Forecast.calDate)=#" & Format(currentDate,
"mm/dd/yyyy") & "#));"
cmd.CommandText = strSQL
Debug.Print strSQL
cmd.Execute
currentDate = currentDate + 1
Loop

And here's the strSQL output in the immediate window:

UPDATE Forecast SET Forecast.totalValue = "totalValue" +263.4528 WHERE
(((Forecast.calDate)=#01/01/2006#));

However, I get a "data type mismatch in criteria expression" error. I
don't
get this error if I remove the #'s, but none of the fields get updated.
Any
ideas?

Thanks,

Dave
 

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