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

    update query code (Access 2000)

    I have an update query which works, it is the following:

    UPDATE products SET products.branch0 = [stock], products.items0 = [items];

    However, when i want to express it with a function it seems that it doesnt work.

    My funnction is the following:


    Public Function MyUpdate()
    Dim strSQL As String
    strSQL = " UPDATE products SET products.branch0 = [stock], products.items0 = [items]"
    CurrentDb.Execute strSQL
    End Function

    Why is it so? and why the function is wrong?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: update query code (Access 2000)

    You haven't provided enough information. What do you mean it doesn't work? Do you get an error message, do fields not get updated, or what? What are [stock] and [items]? Are they fields in the products table or something else?
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: update query code (Access 2000)

    The fields stock ,items,branch0 and item0 are fields in the table products.You could see that from my query where i write products.stock, which means this is a field stock from the table products.Also i do not receive any error, but the fields are not updated.Also,as i mentioned ,the query i have shown is working, but i cannot explain myself why the function is not working, which means that the function is not updating.

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: update query code (Access 2000)

    <hr>The fields stock ,items,branch0 and item0 are fields in the table products. You could see that from my query where i write products.stock<hr>
    You didn't write products.stock anywhere in your post

    So then this is your layout?
    table name
    products
    field list
    stock
    items
    branch0
    item0

    This brings the question, why do you want a pair of identical fields in the same table, branch0=stock and items=item0?

    <hr>Also i do not receive any error, but the fields are not updated.Also,as i mentioned ,the query i have shown is working, but i cannot explain myself why the function is not working, which means that the function is not updating.<hr>
    That may be obvious to you, but we have no way of knowing that you didn't receive any error messages, or that the field didn't update to a vaule you weren't expecting or any of a dozen other possible reasons that you would cause you to say that the function doesn't work.

    All that being said, I would guess, based on the little information provided, is that your SQL statement should probably be:

    strSQL = "UPDATE products SET products.branch0 = " & [stock] & ", products.items0 = " & [items] & ";"
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  5. #5
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: update query code (Access 2000)

    Your suggestion did update ! Thank you.I feel obliged to expplain why i am doing this.The reason is that one ofmy fields will be obsolete in the future the other is brand new and i want to copy the availabe information
    best regards

Posting Permissions

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