Results 1 to 3 of 3
  1. #1
    Freddie81 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    149

    Upating table from anothr Form

    Good day Guys,

    In my database I have a table called ProductsT and in this table, there is a field called StockQty. The idea is to have a field that holds the total stock available of that item.



    I then have a form called StockDataEntryF that is used to capture the buying new stock.

    When I hit Submit button the form I want the Qty that is entered into it to be added to the field in ProductsT called StockQty.

    How would I do this?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Can you post a jpg of your tables and relationships---expand tables to show all fields?
    Here is an often referenced article on Stock/Inventory by Allen Browne.

  3. #3
    John_G is offline VIP
    Windows 10 Access 2016
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    When I hit Submit button the form I want the Qty that is entered into it to be added to the field in ProductsT called StockQty.
    A simple SQL statement in VBA will do that for you. In the code behind you Submit button you could have something like this:

    Code:
    Dim SQL as string
    SQL = "Update ProductsT set StockQty = StockQty + " & me!Qty & " where ProductID = " & Me!ProductID
    Currentdb.Execute SQL,dbfailonerror
    The where clause " where ProductID = " & Me!ProductID is necessary to identify the one record in table ProductsT that you want to update with a new quantity.

    This assumes that the field ProductID in the table is unique for each record; it might be the Primary Key of the table.
    It also assumes that you have a field on the StockDataEntryF form that holds the ProductID.

    Replace the names in italics with the actual names of the fields in the table and on your StockDataEntryF form.

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

Similar Threads

  1. Replies: 6
    Last Post: 12-13-2014, 09:20 PM
  2. Replies: 1
    Last Post: 07-01-2014, 01:41 PM
  3. Replies: 2
    Last Post: 10-07-2013, 11:01 AM
  4. Replies: 2
    Last Post: 01-31-2013, 09:33 PM
  5. Replies: 2
    Last Post: 08-01-2011, 11:35 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