Results 1 to 8 of 8
  1. #1
    George Pollow is offline Advanced Beginner
    Windows 7 32bit Access 2000
    Join Date
    May 2014
    Posts
    30

    Access 2000 Subform expression to calculate the inventory balance by subtracting


    I have a subform containing inventory transactions by date. I want to calculate the inventory balance by subracting the total used from received.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    What is data structure? Do you have a field for the transaction type (used/received) and a single quantity field? Or do you enter positive/negative values in a quantity field?
    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
    George Pollow is offline Advanced Beginner
    Windows 7 32bit Access 2000
    Join Date
    May 2014
    Posts
    30
    I have 2 fields from Pubs Transaction form called 12_In and 12_Out I want to subtract the sum of 12_In from 12_Out to determine "Avail".

    I have a text box in the footer of the subform to do the calculation and a textbox in the body of the parent form to display "Avail" but nothing displays.

  4. #4
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    Math will not calc blanks (nulls) - and so be sure there are 0s; if not write an update query and put 0s in wherever there are nulls; and modify the table property to have a default 0 to avoid more nulls in the future.

    Beyond that; break it down into simple steps to discover your problem i.e. =Sum([12_In]) should work and then try =Sum([12_Out]) ; those must first work as tests in your footer text box....then merge them together: =Sum([12_In]) - Sum([12_Out])

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Populating with 0 should not be necessary but probably wouldn't hurt.

    Simple arithmetic with Null results in Null: [field1] + [field2]. Can handle possible Null with Nz() function: Nz([field1],0)

    Aggregate functions (Sum, Count, Avg, etc) will ignore Nulls and aggregate records that do have values.

    What is the expression in the Avail textbox? Needs to be like:

    =[subform container name].Form!textboxname

    Give the subform container control a name different from the object it holds.

    Is the subform in Datasheet view? Try Continuous View and arrange controls to look like Datasheet. Then the subform footer can be displayed with the summary calcs and no need to have textbox on main form.
    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.

  6. #6
    George Pollow is offline Advanced Beginner
    Windows 7 32bit Access 2000
    Join Date
    May 2014
    Posts
    30
    It still does not work.

    Here is my expression for the subform footer:

    =sum(nz([12_in],0)-nz([12_out],0))

    here is the expression for the form:

    =[pubs transaction subform].[form]![avail]

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  8. #8
    George Pollow is offline Advanced Beginner
    Windows 7 32bit Access 2000
    Join Date
    May 2014
    Posts
    30
    Thank you for your assistance. It helped me get on the right track.

    I was building an expression for each calc under "Build Event". I noticed that there was noting showing in "Control Source" so I added the espression there.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-04-2013, 09:48 AM
  2. Replies: 1
    Last Post: 03-08-2013, 10:29 PM
  3. Replies: 1
    Last Post: 02-21-2013, 12:18 AM
  4. How to calculate current balance on hand
    By fazly lee in forum Access
    Replies: 11
    Last Post: 09-05-2012, 09:16 PM
  5. Replies: 1
    Last Post: 07-10-2012, 05:51 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