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

Syntax error 1

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
Not getting the hang of this stuff. Have the following query:

udq = _
"UPDATE BayCounts " & _
"SET [Count] = " & rsdbo.Fields("Count") - rsdbo.Fields("SumOfBalls") & "," & _
" [AddTime] = #" & TimeValue(Now()) & _
" [AddDate] = #" & DateValue(Now()) & _
"# WHERE ID = " & CInt(Right(rsdbo.Fields("Bayno"), 2))
DoCmd.SetWarnings False
DoCmd.RunSQL udq
DoCmd.SetWarnings True

DebugPrint of query prior to execution =

UPDATE BayCounts SET [Count] = 745, [AddTime] = #11:58:39 AM [AddDate] = #10/29/2012# WHERE ID = 1UPDATE BayCounts SET [Count] = 723, [AddTime] = #12:10:55 PM [AddTime] = #12:10:55 PM# WHERE ID = 1UPDATE BayCounts SET [Count] = 702, #[AddTime] = #12:19:08 PM [AddTime] = #12:19:08 PM# WHERE ID = 1

Run-time error '3075
Syntax error(missing operator) in query expression '12:28:20 PM [AddDate]=#10/29/2012#'
Think there is a # missing, but I've tried amny combination, none of which work

Appreciate the help

jpl

 

[tt]
UPDATE BayCounts SET [Count] = 745, [AddTime] = #11:58:39 AM[red]#, [/red] [AddDate] = #10/29/2012# WHERE ID = 1[/tt]

Have fun.

---- Andy
 
Did you try:
[tt]
udq = _
"UPDATE BayCounts " & _
"SET [Count] = " & rsdbo.Fields("Count") - rsdbo.Fields("SumOfBalls") & "," & _
" [AddTime] = #" & TimeValue(Now()) & _
"[red]#,[/red] [AddDate] = #" & DateValue(Now()) & _
"# WHERE ID = " & CInt(Right(rsdbo.Fields("Bayno"), 2))
[/tt]

Told you [tt]Debug.Print[/tt] is handy... :)

Have fun.

---- Andy
 
Andy, it works. My problem is that I can't subdivide the expression into it's components. I've printed the cribsheet you sent, in this particular piece of sql it escapes me. I will study some more, but in the mean time, thanks so much.

jpl
 
I think I'LL print the expression and break out the Crayola's.

Thanks again
jpl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top