Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DSUM Syntax conundrum

Status
Not open for further replies.

ddelk

Programmer
May 28, 2003
47
0
0
US
I want to put this sql update statement into code but keep getting syntax errros. It works in a query but in sql I have to change all the double quotes to singles and I'm missing something somewhere.

strSql = "UPDATE TEMP SET TEMP.CUMMW = DSum('mw','dispatch_all','[totdispatch]<= " & [TotDispatch] & " and [cntrl_area]<='" & [CNTRL_AREA] & "' and [season]<='" & [SEASON] & "' and [year]<= " & [YEAR] & " and [casename] <= '" & [CaseName] & "')"
Debug.Print strSql
DoCmd.RunSQL strSql
 
What's the result of the debug.print?

------------------------
Hit any User to continue
 
You may try either this:
strSql = "UPDATE TEMP SET TEMP.CUMMW = DSum('mw','dispatch_all','[totdispatch]<= " & [TotDispatch] & " and [cntrl_area]<=""" & [CNTRL_AREA] & """ and [season]<=""" & [SEASON] & """ and [year]<= " & [YEAR] & " and [casename] <= """ & [CaseName] & """)"
Or this:
strSql = "UPDATE TEMP SET TEMP.CUMMW = DSum('mw','dispatch_all',""[totdispatch]<= " & [TotDispatch] & " and [cntrl_area]<='" & [CNTRL_AREA] & "' and [season]<='" & [SEASON] & "' and [year]<= " & [YEAR] & " and [casename] <= '" & [CaseName] & "'"")"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top