Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2005
    Posts
    102

    Unanswered: A RunSQL action requires an argument consisting of an SQL statement

    Hi guys,

    I have this code I inserted on a On Click event of a command button awhile back. The code looks like this

    DoCmd.OpenQuery "qryEditItemOnOrder", acNormal, acEdit

    Now, I want to eliminate the object (qryEditItemOnOrder) from my DB... So I replaced the above code with this one

    DoCmd.RunSQL "SELECT tblTodaysOrder.PAR, tblTodaysOrder.CAB, tblTodaysOrder.SUB, tblTodaysOrder.QTY, " & _
    "tblTodaysOrder.HMMS, tblTodaysOrder.ItemDescription, tblTodaysOrder.DistributionUnit, " & _
    "tblTodaysOrder.UnitPrice, tblTodaysOrder.Total, tblTodaysOrder.DeptObj, tblTodaysOrder.MinObj, " & _
    "tblTodaysOrder.UnitCode, tblTodaysOrder.Date, tblTodaysOrder.Time, tblTodaysOrder.InventoryStaff, " & _
    "tblTodaysOrder.Barcode FROM tblTodaysOrder WHERE (((tblTodaysOrder.Barcode)=[Enter Barcode # (ParCabSub)]));"

    Instead of the query running properly like how it use to when it was an object, rather I get this message saying "A RunSQL action requires an argument consisting of an SQL statement"....

    What does this mean?

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ????
    Enter Barcode # (ParCabSub)

    since you've gone to the trouble of writing SQL in a form instead of using A's ghastly parameter queries, why not be nice to the user and give them some space on the form to type the barcode.

    then the last bit of your SQL reads

    if numeric:
    WHERE (((tblTodaysOrder.Barcode)=" & me.myBarCodeTextbox & "));"

    if string:
    WHERE (((tblTodaysOrder.Barcode)='" & me.myBarCodeTextbox & "'));"

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    and to reply to your question:

    .runsql takes only action queries
    DELETE
    UPDATE
    INSERT
    etc

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Jun 2005
    Posts
    102
    Hey thanks alot izy, I took your advice and created a textbox where user can enter input... It works great...

    One more question, I'm trying to hide a button (1st button on form) after it has been clicked, but Access tells me this error "You can't hide a control that has the focus."

    I really don't want to let the user see this button after it has been clicked. How do I make the focus move to the next command button?

    By the way, the next command button is only visible after the 1st button is clicked.

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so use the setfocus function to force the focus to move somewhere else, and then disable the control...

  6. #6
    Join Date
    Jun 2005
    Posts
    102
    Got it, thanx!

Posting Permissions

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