troubleshooting Question

Problems with DoCmd.RunSQL in Access 2003 and SQL 2008 database

Avatar of compuzak1
compuzak1 asked on
Microsoft SQL Server 2008Microsoft Access
5 Comments1 Solution1201 ViewsLast Modified:
I have a simple SQL statement that updates records in a table from records in the same table.  The SQL works fine in SQL 2008 Server Management Tool as a stored procedure.  When I try to run it via the DoCmd.RunSQL it gives me a runtime error 3075 with a message of a syntax error (missing operator).  I copy the exact string Access is creating and paste it into a SQL2008 script and it save it as a stored procedure and it executes perfectly.  

Obviously there is some limitations or differences between Access DoCmd.RunSQL and running a stored procedure directly in SQL 2008.  I am able to run other SQL commands but so far nothing with an INNER JOIN.

Here is the Code:
    DoCmd.SetWarnings False
    strSQL = "UPDATE  t1 " & _
             " SET     LaneIdx = t2.LaneIdx, " & _
             "         StyleIdx = t2.StyleIdx, " & _
             "         SizeIdx = t2.SizeIdx, " & _
             "         GradeIdx = t2.GradeIdx , " & _
             "         LabelIdx = t2.LabelIdx " & _
             " FROM    dbo_TblLaneCfgDet t1 " & _
             " INNER JOIN dbo_TblLaneCfgDet t2 on t2.LaneIdx = t1.LaneIdx " & _
             " AND t2.LaneCfgHdrIdx = " & OrigLaneCfgHdrIdx & _
             " WHERE   t1.LaneCfgHdrIdx = " & NewLaneCfgHdrIdx
    DoCmd.RunSQL strSQL

If someone can tell me how to fix the syntax so that it will work for Access that would work.  

If not, can someone show me the Access 2003 syntax to call a stored procedure from SQL 2008 including the connection logic:
proc:  usp_CopyLaneConfig
parm1: INT
parm2: INT

The stored procedure method is preferred, but I am having problems with the exact syntax from Acess 2003.  I call stored procedures in Visual 2008 C# without any problems, very straightforward syntax, but I am having problems in Access.  The help in Access 2003 is limited at best (at least for me).


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros