Results 1 to 5 of 5
  1. #1
    jjz0512 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    55

    Question Creating a Balance # from multiple fields on a form

    I have a problem that I will try to explain. I have a Access UI link to an Oracle database. In one of the tables, CME, I have 10 CME Expense element and a Balance of CME stored in the table. That populated with data, if available, that was stored for an ID. When I add 7CME information, 7CME Expense Desc, 7CME Expense & 7CME Date Paid, whenever I, move to another field, click the Refresh Button or change to another tab form, I would like to update Balance of CME with the amount entered and/or the sum of 1-10CME Expense fields. Balance of CME can come from the table, CME, when I first populate the form, and I need to updated it when ever an 1-10CME expense is inserted or updated. But don't know how to do it. The control source for Balance of CME is the element CME.BALANCE_OF_CME. I included a copy of the form.



    Click image for larger version. 

Name:	CME.png 
Views:	16 
Size:	10.9 KB 
ID:	23834

    Thanks for your help, it's much appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Option 1 would be to fix the design, which is not normalized:

    Fundamentals of Relational Database Design -- r937.com

    Presuming that won't be done, I'd create a form level function that added the 10 amount fields and put the result in the total textbox, and call that function from the after update event of the 10 amount textboxes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jjz0512 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    55
    pbaldy, no, the database won't be changed, it's a inherited UI and Database. I not sure what you mean by a form level function, as I'm relatively new to this.

  4. #4
    jjz0512 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    55
    I got it to work. I entered code for each CME_Expense, after update, of;
    Code:
    Forms("DEMOGRAPHICS").[CME].Form.[BALANCE_OF_CME] = Nz(Forms("DEMOGRAPHICS").[CME].Form.[1CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[2CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[3CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[4CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[5CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[6CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[7CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[8CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[9CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[9CME_expense], 0) + Nz(Forms("DEMOGRAPHICS").[CME].Form.[10CME_expense], 0)
    But had to create 10 subs, is there an easier way?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Yes, the function I mentioned, called from each event. See if this helps:

    http://www.baldyweb.com/Function.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 12-30-2015, 04:26 PM
  2. General Ledger Query With Opening Balance and Running Balance
    By muhammadirfanghori in forum Queries
    Replies: 3
    Last Post: 03-12-2015, 07:17 AM
  3. Replies: 3
    Last Post: 07-18-2014, 10:50 AM
  4. Replies: 17
    Last Post: 06-17-2014, 08:07 AM
  5. Replies: 6
    Last Post: 09-14-2013, 05:59 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