Help with syntax error

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!
 
V

vanderghast

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
 
J

Jinjer

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"
 
M

Marshall Barton

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"
 

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