Results 1 to 4 of 4
  1. #1
    shanea.kr is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    3

    Subtract from one record and add to another in access

    In my database I have a list of organizations with a certain goal. If that organization can not hit that goal we have to "reallocate" the left over goal to another organization. As it stands now I have the following fields, Goal (which should stay stagnant), change (to either subtract from one organization and add to another) and New. What I would like to do is have a way to have a way to calculate if there is a change to maybe have a drop drown that when the change is subtracted I can add that to "new" of another organization.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Saving aggregate data is usually a bad idea. Best practice would be to enter 'transactions', one to reduce an organization goal and another to increase an organization goal. Queries would calculate sum of transactions to derive the net change in goal. This will give you an auditable trail for the changes. Otherwise, if something goes wrong, how will you fix? Do you have paper backup?

    However, if you really want to 'adjust' the Change field, can use VBA code to accomplish. Have a combobox to select organization to reallocate to the an UPDATE sql action could modify the record in table.
    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
    shanea.kr is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    3
    Would I do the Combobox and sql action in a form, query?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I would use VBA to execute SQL. Real trick is figuring out what event to put the code in - button Click, combobox AfterUpdate?

    CurrentDb.Execute "UPDATE tablename SET Change = Change - " & Me.textbox & " WHERE ID = " & Me.combobox

    This assumes value from combobox is a number ID for the selected organization.
    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. Query: Subtract totals from different tables
    By joannakf in forum Queries
    Replies: 3
    Last Post: 12-22-2011, 01:39 PM
  2. Subtract from Previous Row
    By lambo102 in forum Queries
    Replies: 1
    Last Post: 08-06-2011, 09:39 AM
  3. How to do subtract in Query
    By NoOoN in forum Queries
    Replies: 6
    Last Post: 04-07-2011, 01:15 PM
  4. Subtract from inventory
    By NISMOJim in forum Access
    Replies: 5
    Last Post: 01-30-2011, 01:09 PM
  5. Subtract From Previous Record Using a Date
    By txrules in forum Queries
    Replies: 1
    Last Post: 12-30-2010, 02:10 AM

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