Results 1 to 5 of 5
  1. #1
    samos1023 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    18

    update statement syntax

    This line of code works fine:


    dbs.Execute "UPDATE tblStockInventory SET Used = false WHERE ID = 22"

    This line of code gives me this error : Runtime error 3075 Syntax error missing operator in query expression 'ID='
    dbs.Execute "UPDATE tblStockInventory SET Used = false WHERE ID = " & txtStockItemId.Value



    what am i doing wrong?
    txtStockItemId is a control on my form

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,824
    Is ID a number type field? Is the value in txtStockItemID a number? txtStockItemID is name of textbox? Use Me. to see if the intellisense popup lists the textbox name.

    I don't see anything wrong with syntax, assuming ID is a number.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    samos1023 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    18
    dbs.Execute "UPDATE tblStockInventory SET Used = false WHERE [ID] = " & Me.txtStockItemID.Value get error on this still

    intellisense worked, the value in the textbox is 22
    still same error.
    im stumped
    seems very simpl

    Used is a yes/no its fine to set it to false right?

  4. #4
    samos1023 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    18
    fixed the problem but dont know why the new way is any different?

    New Code that works
    sSQL = "UPDATE tblStockInventory SET Used = no WHERE [ID] = " & Me.txtStockItemID.Value
    dbs.Execute sSQL

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,824
    True and False work for me as well as Yes and No.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Syntax Error in UPDATE Statement
    By McArthurGDM in forum Programming
    Replies: 5
    Last Post: 02-24-2015, 04:50 PM
  2. Syntax error in SQL UPDATE statement
    By Pietro in forum Modules
    Replies: 1
    Last Post: 02-20-2015, 05:09 AM
  3. sql update statement syntax error
    By osupratt in forum Queries
    Replies: 7
    Last Post: 10-18-2013, 07:42 AM
  4. Syntax error in UPDATE statement HELP!
    By asmith78 in forum SQL Server
    Replies: 5
    Last Post: 09-07-2011, 05:50 PM
  5. UPDATE Statement Correct Syntax
    By OMGsh Y did I say Yes in forum Forms
    Replies: 2
    Last Post: 02-23-2011, 01:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums