Results 1 to 6 of 6

Thread: SQL error

  1. #1
    Join Date
    Mar 2004
    Posts
    128

    Unanswered: SQL error

    Hey,
    I'm trying to write RunSQL command.I copied the SQL statment from the
    SQL view and pasted it with the RunSQL.
    Access give me the exception "A RunSQL action requires an argument
    consisting of SQL statment"
    I thought that somthing wrong in the copy-past so I tried many times and the same exception was displayed.
    What can be the problem
    Thanks...

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346

    Re: SQL error

    Please paste your code here so the forum can investigate what may be the problem.
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    best is to post the SQL you are trying to copy/paste: there are "divergences" between normal SQL, the SQL generated by A's query-view-SQL, and the SQL accepted by A in .runsql

    one of the things to check is that anything refering to vars or textboxes on forms is correctly concatenated:

    WHERE stringField = '" & anyStringVarOrBox & "' restofsql....
    and/or
    WHERE numericField = " & anyNumericVarOrBox & " restofsql....
    and/or
    WHERE dateField = #" & anyDateVarOrBox & "# restofsql....
    etc.......

    usually you can spot these easily with a
    msgbox strSQL
    immediately after you have generated the SQL

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Mar 2004
    Posts
    128

    Re: SQL error

    Originally posted by SCIROCCO
    Please paste your code here so the forum can investigate what may be the problem.

    Here is the code:
    DoCmd.RunSQL "SELECT T.B, T.O, T.S, T.C FROM T LEFT JOIN R ON T.O = R.O WHERE (((R.O) Is Null)); ", -1

    DoCmd.RunSQL "SELECT T.B, T.O, T.S, T.C FROM T LEFT JOIN R ON T.O = R.O WHERE (((R.O) Is Null)); ", -1

    DoCmd.RunSQL "INSERT INTO R ( B, O, S, C ) SELECT [Q].B, [Q].O, [Q].S, [Q].C FROM [Q], R; ", -1



  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: SQL error

    Originally posted by wasimf
    In the first and the second statements there is no actions to be done, like INSERT INTO , DELET FROM or SELECT .... INTO
    So that you can not use the DoCmd.Run Sql (yourSql)

    The third one is ok....

  6. #6
    Join Date
    Mar 2004
    Posts
    128

    Re: SQL error

    Originally posted by hammbakka
    In the first and the second statements there is no actions to be done, like INSERT INTO , DELET FROM or SELECT .... INTO
    So that you can not use the DoCmd.Run Sql (yourSql)

    The third one is ok....

    Hello hammbakka,
    You don't give me your suggestion.I want a way to do my queries in Vb.
    I have 10 tables,if I make two queries to each table,it isn't suitable.
    please give me a link to learn how I can build SQL statments in VB and give them parameters to do the same thing in all of the tables...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •