Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba
Thread: Update query: Data type mismatch

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Update query: Data type mismatch
David M C 05.09.2006 14:27:02
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
Re: Update query: Data type mismatch
"Duane Hookom" <DuaneAtNoSpanHookomDotNet> 05.09.2006 14:41:10
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" <DavidMC[ at ]discussions.microsoft.com> wrote in message
news:DD657682-4A3C-44B4-BDC1-E8CF7E831777[ at ]microsoft.com...
[Quoted Text]
> 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


Re: Update query: Data type mismatch
David M C 05.09.2006 15:50:02
Thanks, sorted.

"Duane Hookom" wrote:

[Quoted Text]
> 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" <DavidMC[ at ]discussions.microsoft.com> wrote in message
> news:DD657682-4A3C-44B4-BDC1-E8CF7E831777[ at ]microsoft.com...
> > 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
>
>
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net