Results 1 to 5 of 5
  1. #1
    twmr2000 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    3

    Update table from vba on loop

    I have a table named tblItems with a field "Qty"


    I have another table, tblItemsSold, with fields "InvNo" for invoices number and "QtySold"
    Both have UPC (barcode) fields.

    What I need to do is when the "Complete" button is clicked:
    All the Items (by UPC) with the same invoice number (InvNo) need to subtract the "QtySold" in tblItemsSold from "Qty" in tblItems.

    I would like to do this through VBA so I can just plug it into the existing code I have.

    I am rushed typing this ATM, so sorry if I left anything out that may make this confusing.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I would recommend just creating an Update Query that does this. You can call (open & run) the Update Query from your VBA code with the OpenQuery command (see: http://msdn.microsoft.com/en-us/libr.../ff192746.aspx).

  3. #3
    twmr2000 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    3
    I'm sorry, but do you have an example? I'm having trouble implementing this.

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Which part are you having trouble with?
    Do you know how to create an Update Query?
    If not, see here: http://office.microsoft.com/en-us/ac...010076527.aspx

  5. #5
    twmr2000 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    3
    Scanning through the link you posted looks like maybe what I am after. When I have more time later I will give it a shot. Thanks. I will let you know.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-17-2013, 08:35 AM
  2. How to update subform records using loop
    By tahirsatti in forum Forms
    Replies: 15
    Last Post: 05-13-2013, 01:22 AM
  3. Replies: 3
    Last Post: 03-10-2013, 07:04 AM
  4. Replies: 1
    Last Post: 06-15-2012, 10:47 AM
  5. update table in loop based on IF statement
    By LALouw in forum Access
    Replies: 0
    Last Post: 07-26-2009, 08:46 PM

Tags for this Thread

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