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 Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another query problem 4

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
Had to Change a query that I got help on from here, here is the new version

udq = _
"UPDATE BayCounts " & _
"SET [Count]=" & rsdbo.Fields("StCount") - rsdbo.Fields("SumOfBalls") & _
"WHERE ID=" & CInt(Right(rsdbo.Fields("Bayno"), 2))

Syntax error (missing operator) in query expression '98WHERE ID = 1'

All the fields in the query return the correct results in the immediate window.


Thanks

jpl


 
Syntax error (missing operator) in query expression '[red]98WHERE[/red] ID = 1'

Perhaps a missing SPACE?


Randy
 
[highlight] [/highlight]WHERE ID=" & CInt(Right(rsdbo.Fields("Bayno"), 2))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I don't see where. Tried adding a space In "WHERE ID =" & CInt(Right(rsdbo.Fields("Bayno"), 2)) after the ID but get the same error.

jpl
 
Tried Changing it to:
"UPDATE BayCounts " & _
"SET [Count]=" & rsdbo.Fields("StCount") - rsdbo.Fields("SumOfBalls") & _
"WHERE ID=" & CInt(Right(rsdbo.Fields("Bayno"), 2))

and get the same error

jpl

 
Again, add the space before the WHERE.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Putting the space before the WHERE worked. I thought I had a space in the previous line before the break character. In the

udq = _
"UPDATE BayCounts " & _
"SET [Count]=" & rsdbo.Fields("StCount") - rsdbo.Fields("SumOfBalls") & _
" WHERE ID=" & CInt(Right(rsdbo.Fields("Bayno"), 2))

Are there not now two spaces prior to the WHERE, one in the previous line and one directly before the WHERE? It's running and giving the proper results. Why the two spaces?

Thanks again

jpl
 
I don't know where you have a space in the previous line. You might want to use some debugging to find your errors:

Code:
udq = _
"UPDATE BayCounts " & _
"SET [Count]=" & rsdbo.Fields("StCount") - rsdbo.Fields("SumOfBalls") & _
" WHERE ID=" & CInt(Right(rsdbo.Fields("Bayno"), 2))
Debug.Print udq

Duane
Hook'D on Access
MS Access MVP
 
These
Code:
"SET = ...("SumOfBalls")[COLOR=black yellow] [/color]&[COLOR=black yellow] [/color]_

ARE NOT spaces in the SQL statement. They are a part of the VBA syntax. If you wanted a space there then you would need to explicitly put it in.

Code:
"SET = ... ("SumOfBalls")[red] & " " [/red]& _
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top