UserName935
asked on
VBA SQL update query
sometimes I f'ing hate access, SSMS take me away......
Access 2010, win7
Issue: SQL VBA Update query not functioning.
Error: Syntax error on update statement
Yes, I dimmed strUpdateSQL string
Statement:
strUpdateSQL = "UPDATE MOR_ChartDBSource_Template " _
& "SET (MOR_ChartDBSource_Templat e.Jan = '" & ResultString & "')" _
& "WHERE ((MOR_ChartDBSource_Templa te.YEAR) Like '2014') AND ((MOR_ChartDBSource_Templa te.CHARTDB _BIN) Like 'calcHC')" _
& "AND (MOR_ChartDBSource_Templat e.ORG_ABBR Like 'Total') AND (MOR_ChartDBSource_Templat e.MOR_GROU P Like 'CE Prog Other')"
DoCmd.RunSQL strUpdateSQL
Access 2010, win7
Issue: SQL VBA Update query not functioning.
Error: Syntax error on update statement
Yes, I dimmed strUpdateSQL string
Statement:
strUpdateSQL = "UPDATE MOR_ChartDBSource_Template
& "SET (MOR_ChartDBSource_Templat
& "WHERE ((MOR_ChartDBSource_Templa
& "AND (MOR_ChartDBSource_Templat
DoCmd.RunSQL strUpdateSQL
ASKER
Umm NICE TRY !!
It blew up, when pasting into the vba it all turn red, so I made some changes and it continues to fail to function.
This is what I changed it to.
strUpdateSQL = "UPDATE MOR_ChartDBSource_Template " & _
"SET (MOR_ChartDBSource_Templat e.Jan = '" & ResultString & "')" & _
"WHERE ((MOR_ChartDBSource_Templa te.YEAR) Like '2014') AND " & _
"((MOR_ChartDBSource_Templ ate.CHARTD B_BIN) Like 'calcHC') " & _
"AND (MOR_ChartDBSource_Templat e.ORG_ABBR Like 'Total') AND " & _
"(MOR_ChartDBSource_Templa te.MOR_GRO UP Like 'CE Prog Other')"
DoCmd.RunSQL strUpdateSQL
It blew up, when pasting into the vba it all turn red, so I made some changes and it continues to fail to function.
This is what I changed it to.
strUpdateSQL = "UPDATE MOR_ChartDBSource_Template
"SET (MOR_ChartDBSource_Templat
"WHERE ((MOR_ChartDBSource_Templa
"((MOR_ChartDBSource_Templ
"AND (MOR_ChartDBSource_Templat
"(MOR_ChartDBSource_Templa
DoCmd.RunSQL strUpdateSQL
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
PAY-DIRT !!!! What the Heck !!
AAHHH, It was these things ( ).
Awesome, thank you !!!!!!
AAHHH, It was these things ( ).
Awesome, thank you !!!!!!
Glad I could help.
For future reference the Access query builder puts in a bunch of wasteful parentheses.
About the only time you need the parentheses is if you are using the IN keyword or combining AND and OR statements.
For future reference the Access query builder puts in a bunch of wasteful parentheses.
About the only time you need the parentheses is if you are using the IN keyword or combining AND and OR statements.
strUpdateSQL = "UPDATE MOR_ChartDBSource_Template
& "SET (MOR_ChartDBSource_Templat
& "WHERE ((MOR_ChartDBSource_Templa
& "AND (MOR_ChartDBSource_Templat
DoCmd.RunSQL strUpdateSQL