Results 1 to 3 of 3

Thread: What is the problem here?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    Medford,MA,USA
    Posts
    23

    Post

    Hi All,
    I am trying to update a field in an access table via ADO and SQL. I am getting a syntax error which I am not able to resolve. Basically, the field is updated based on the quantity in the text box and the item selected in the list box. I am getting an error message when I include the WHERE clause of the SQL statement and I don’t get any error messages when I don’t have it. So, the problem is in how I am representing the item selected in the list box. Any help appreciated.

    Public objCmd As New ADODB.Command

    objCmd.CommandText = "Update PO_Table Set Quantity=" & txtQty & "Where PO_number=" & "'" & lstPO.Text & "'"

    Also, could you recommend any sites/books that specifically talk about SQL syntax in a VB environment.

    Thanks
    Zack

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    Put a space in front of the WHERE - also might as well put the ' inside - make it look nicer:

    objCmd.CommandText = "Update PO_Table Set Quantity=" & txtQty & " Where PO_number= '" & lstPO.Text & "'"


    That should work.

    That is assuming the the PO_number is a text field and not a number field - if it is a number field ten yo uhave to remove the ' and change the lstPO.text to that number type (CINT, CLNG etc).

    Edited by netSurfer on 03-13-2000 at 11:29 AM

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    Medford,MA,USA
    Posts
    23

    Post

    Thanks Netsurfer, the space in front of the where clause worked.
    Zack

Posting Permissions

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



Click Here to Expand Forum to Full Width