Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update only one product? (Access 2000)

    Can somebody help me ? I have a table called products, with ProductID as autonumber.I need to set the value to 0 only for one
    product, which is the number 176. I have a working function that sets all the value to 0, and it is the following
    Public Function CleanFields()
    Dim StrVa As String
    StrVa = " UPDATE products SET branch1 = 0"
    CurrentDb.Execute StrVa
    End Function
    However i want to set the value only for one product, whch is

    number 176, that is ProductID = 176.I cannot do it.I have tried
    the folowing code without success:
    Public Function CleanFields()
    Dim StrVa As String
    StrVa = " UPDATE products.productid .products.branch1 WHERE

    Products.ProductID = 176"
    CurrentDb.Execute StrVa
    End Function
    The message is "Syntax error"

    I will be grateful for any help

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update only one product? (Access 2000)

    The syntax is "UPDATE TableName SET FieldName = Value WHERE Condition". In your case, add the condition to your original SQL string:

    StrVa = "UPDATE Products SET Branch1 = 0 WHERE ProductID = 176"

Posting Permissions

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