Error 2501 when executing a VBA query

Posted on 2005-04-17
Last Modified: 2012-05-05
I have been creating the queries from the Access 2003 database design view, then copy the code into my procedures once I am sure they give me the results I want.  This has been working fine until now.  The below is the code I copied from a working query but now when I try to run it in the procedure, I get a Runtime 2501 error, RUnSQL was canceled.  The only modificiation was changing the " to '.  Any suggestions?  

strMakeTable = "SELECT tblWeeklyUpload.AssignmentDate, tblWeeklyUpload.DateWorkedOn, " & _
               "tblWeeklyUpload.Lots, IIf([Transcode]='JNL','JNL (2)','') AS TranCode, " & _
               "[DateWorkedOn]-[tblWeeklyUpload.AssignmentDate] AS DaysDiff, tblSLA.SLA, " & _
               "IIf([SLA]>=[DaysDiff],'Yes','No') AS Met, tblSPCQualityControl.IndiaRanking,  " & _
               "tblSPCQualityControl.Ranking AS SFReviewRanking INTO tblIndiaJNLMetrics " & _
               "FROM (tblWeeklyUpload LEFT JOIN tblSLA ON tblWeeklyUpload.TransCode = tblSLA.ReturnMethod) " & _
               "LEFT JOIN tblSPCQualityControl ON tblWeeklyUpload.Account = tblSPCQualityControl.Account " & _
               "WHERE (((tblWeeklyUpload.AssignmentDate) Between [FORMS]![frmMenuManagementIndia].[txtStart] " & _
               "And [FORMS]![frmMenuManagementIndia].[txtEnd]) AND ((tblWeeklyUpload.TransCode)= 'JNL') AND " & _
               "((tblWeeklyUpload.EditTeam)='India')) "
Question by:ssmith94015
    LVL 48

    Accepted Solution

    Try this:

                   "WHERE (((tblWeeklyUpload.AssignmentDate) Between #" & [FORMS]![frmMenuManagementIndia].[txtStart] & "# " & _
                   "And #" & [FORMS]![frmMenuManagementIndia].[txtEnd] & "#) AND ((tblWeeklyUpload.TransCode)= 'JNL') AND " & _

    or if you don't use the "reverse" US date format:

    strDateStart = Format([FORMS]![frmMenuManagementIndia].[txtStart], "m\/d\/yyyy")
    strDateEnd = Format([FORMS]![frmMenuManagementIndia].[txtEnd], "m\/d\/yyyy")

                   "WHERE (((tblWeeklyUpload.AssignmentDate) Between #" & strDateStart & "# " & _
                   "And #" & strDateEnd & "# AND ((tblWeeklyUpload.TransCode)= 'JNL') AND " & _

    LVL 25

    Expert Comment

    Did you get this working?

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
    Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now