Results 1 to 6 of 6
  1. #1
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49

    Display subtotal from subform in main form

    I'm using Access 2010 and have a subtotal displaying in a subform called FORM_ExpenseTransactionDetails. I created a field in the main form (FORM_ExpenseTransactions) and referred to the subtotal field, or at least I thought I did.



    The field displays #Name? in Form View and I've tried a variety of things to solve the issue, but to no avail.

    I've attached the file for review. If anyone can point me in the right direction, I would really appreciate it.

    Thanks!
    Doug
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You could put a txt box in the footer of the sub-form. =sum([myfield]) (name it txtSubTotal)
    then put another txtBox in the main form that looks at it.. =forms!frmMain!subForm.form.txtSubtotal
    (ALWAYS use the builder to get the path correct)

    or

    make a query that summs the data based on the master key...qsSumSubTot
    then the mainform txtBox = dLookup("[total]",qsSumSubTot)
    BUT you have to refresh it on record change.

  3. #3
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49
    Hi ranman,

    Thanks for the input, I really appreciate it! I created a query as you suggested and called it ExpenseSubtotals. Following is the SQL code from the query:

    Code:
    SELECT TBL_TransactionDetails.TransactionID, TBL_Transactions.TransactionCounterParty, Sum([ExpenseAmount]-[IncomeAmount]) AS SubtotalFROM TBL_Transactions INNER JOIN TBL_TransactionDetails ON TBL_Transactions.TransactionID = TBL_TransactionDetails.TransactionID
    GROUP BY TBL_TransactionDetails.TransactionID, TBL_Transactions.TransactionCounterParty, TBL_TransactionDetails.IncomeAmount
    HAVING (((TBL_TransactionDetails.IncomeAmount)<=0));
    In the Control Source property of the text box in the main form, I entered "=DLookUp("[Subtotal]",[ExpenseSubtotals],[TransactionID])". However, I'm getting the same error message as before. Am I doing something wrong?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Try:

    =DLookUp("[Subtotal]", "[ExpenseSubtotals]", "TransactionID=" & [TransactionID])

    Actually, it should automatically recalculate when navigating records. Domain aggregates can perform slowly. You might even see a delay in the textbox recalc.
    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.

  5. #5
    dougdrex is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    49
    June7,

    That worked perfectly!!

    Do you mind explaining the logic behind that syntax and where I went wrong in my previous attempt? I'd like to learn from this experience so I don't run into a similar issue in the future.

    Thank you SO MUCH!!!
    Doug

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    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. Replies: 2
    Last Post: 10-22-2014, 11:39 AM
  2. Replies: 1
    Last Post: 08-05-2014, 03:36 AM
  3. How to display multiple Subform in main form
    By selvakumar.arc in forum Forms
    Replies: 5
    Last Post: 05-06-2013, 11:42 AM
  4. Replies: 4
    Last Post: 02-04-2012, 12:51 PM
  5. Subform won't display in main form
    By Lynn in forum Forms
    Replies: 15
    Last Post: 03-22-2010, 10:17 AM

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