Help with syntax error

  • Thread starter Thread starter Opal
  • Start date Start date
O

Opal

Could someone help me debug this in Access 2003?

I have been staring at it all afternoon and I can't seem to
get it:

strQuery = "UPDATE CMMonth " & _
"SET Countermeasure = '" & Countermeasure &
"'" _
" WHERE PartNo = '" & HoldPartNo & "'" _
" AND WeekNo =" & HoldWeekNo & _
" AND CMYear =" & HoldCMYear & _
" AND CarryOver = -1"

Thank you!
 
Missing two &? Have you tried:


strQuery = "UPDATE CMMonth " & _
"SET Countermeasure = '" & Countermeasure & "'" & _
" WHERE PartNo = '" & HoldPartNo & "'" & _
" AND WeekNo =" & HoldWeekNo & _
" AND CMYear =" & HoldCMYear & _
" AND CarryOver = -1"


I assume Countermeasure, neither HoldPartNo, has a ' in them.

Those statements can be debug by making a stop point right after them, then,
at runtime, debug.print strQuery and if the error is still eluding you,
paste the result (from the Immediate Window) into a new query SQL view.



Vanderghast, Access MVP
 
Hi, Opal.

You are missing an ampersand. Here's the code:

strQuery = "UPDATE CMMonth " & _
"SET Countermeasure = '" & Countermeasure & "'" & _
" WHERE PartNo = '" & HoldPartNo & "'" _
" AND WeekNo =" & HoldWeekNo & _
" AND CMYear =" & HoldCMYear & _
" AND CarryOver = -1"
 
Opal said:
Could someone help me debug this in Access 2003?

I have been staring at it all afternoon and I can't seem to
get it:

strQuery = "UPDATE CMMonth " & _
"SET Countermeasure = '" & Countermeasure &
"'" _
" WHERE PartNo = '" & HoldPartNo & "'" _
" AND WeekNo =" & HoldWeekNo & _
" AND CMYear =" & HoldCMYear & _
" AND CarryOver = -1"


You're missing the & at the end of some lines:

strQuery = "UPDATE CMMonth " & _
"SET Countermeasure = '" & Countermeasure & "'" & _
" WHERE PartNo = '" & HoldPartNo & "'" & _
" AND WeekNo =" & HoldWeekNo & _
" AND CMYear =" & HoldCMYear & _
" AND CarryOver = -1"
 
Back
Top