Access query help needed !!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • titli
    New Member
    • May 2010
    • 26

    Access query help needed !!

    I want to run a update query
    Code:
    accApp.OpenCurrentDatabase sRawDatabaseName
    accApp.DoCmd.TransferText acImportDelim, "DataImportSpec", "tblRaw", sLocalDataFile, False
    accApp.DoCmd.RunSQL  "Update tblRaw SET tblData.MaturityDate="" WHERE BookCode="123-America" AND StrategyID IN('420','320','220');"
    This sRawDatabaseNam e is C:\Documents and Settings\All Users\Documents \Data.mdb

    Access doesn't accept this SQL
    Code:
    "Update tblRaw SET tblData.MaturityDate="" WHERE BookCode="123-America" AND StrategyID IN('420','320','220');"
    Whereas I run it , by saving the intermediate database and it works fine .I run in that database manually
    Code:
    Update tblData SET MaturityDate=""  WHERE BookCode="123-America" AND StrategyID IN('420','320','220');
    Please help immediately if possible.Many thanks in advance !!
    Last edited by NeoPa; Jun 30 '10, 01:12 PM. Reason: Please use the [CODE] tags provided.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    Your setting of :
    Code:
    MaturityDate=""
    will not work as you have it from within a SQL string. It will see that as :
    Code:
    MaturityDate="
    See Quotes (') and Double-Quotes (") - Where and When to use them.

    Comment

    • thelonelyghost
      New Member
      • Jun 2010
      • 109

      #3
      First off, for the sake of clarity, don't be afraid to use the [CODE] boxes in this forum.

      Onto your issue. Your SQL is in the form of a string. What this means is that Access chokes when you use quotes in the way you did:
      Code:
      "Update tblRaw SET tblData.MaturityDate="" WHERE BookCode="123-America" AND StrategyID IN('420','320','220');"
      It currently sees it as three separate strings:

      Code:
      Update tblRaw SET tblData.MaturityDate=" WHERE BookCode=
      123-America
       AND StrategyID IN('420','320','220');
      The above doesn't even have any sort of concatenation symbol ( & ) so Access panics and doesn't know what to do. If you change it to this, it may solve your issue:
      Code:
      "Update tblRaw SET tblData.MaturityDate='' WHERE BookCode='123-America' AND StrategyID IN('420','320','220');"
      EDIT: Nice link, NeoPa! I didn't know it existed, but c'est tres utile!

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        Thanks LePhantasmSeul :)

        We have a bunch of articles on the site in Access. I try to link to them where I can. It saves reinventing the wheel every time, which can get a little tedious.

        PS. I just got back from Paris at the weekend so my French is as good as it gets ATM :D

        Comment

        • titli
          New Member
          • May 2010
          • 26

          #5
          Thanks All ...for your responses and explanations... .Yes, the last update query in the link , worked fine.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            Thanks for the response Titli. Glad that helped.

            I'm going to set post #3 as best as the explanation there is the clearest and fullest.

            Comment

            Working...