Results 1 to 7 of 7
  1. #1
    atai is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    22

    How to add a total of a subform field visible on the main form

    Hello


    I have a text box in the footer of the subform called Tot_qta where I sum the field "qta" = sum ([qta]).
    Then I have a text box in the main form that should make me see this total.
    The name of the subform control is "maschera_item"
    If I put = [Maschera_item]. [Form]! [Qta], obviously shows me the quantity of the first row
    if I replace qta with tot_qta it gives me error.
    Can somebody explain me how to solve this issue?
    Many thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    What error?

    What you have referencing textbox name should work but try using dot instead of bang.

    =Maschera_item.Form.Tot_qta

    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.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    design the subform,
    in the footer of the subform add the text box,
    for the formula ,sum the field you want: =SUM([field])
    the main form can see this field.

  4. #4
    atai is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    22
    Quote Originally Posted by June7 View Post
    What error?

    What you have referencing textbox name should work but try using dot instead of bang.

    =Maschera_item.Form.Tot_qta

    If you want to provide db for analysis, follow instructions at bottom of my post.
    the error that show is ?name
    If I change the bang to dot then the system place back the bang

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I use Access 2010 and not seeing that behavior.

    ?Name error means Access cannot find referenced object.

    Can't help if I can't review db.
    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
    atai is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    22
    I found that DSum works on the text box control.
    Now I need to find a way to refresh the text box value everytime I insert a new row.
    I believe I have to use the after updating event on by subform but what is exactly the vba code to insert to update the text box on the main form?
    Name of the main form is "Maschera1"
    Name of the text box where is the Dsum is "totale_qta"
    Thanks

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Domain aggregate is an inefficient method for this. Why are you using DSum()? I thought the Sum() was working?

    You previously stated footer textbox is named tot_qta - now it is named totale_qta?
    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: 3
    Last Post: 06-29-2017, 03:02 PM
  2. Replies: 1
    Last Post: 03-21-2016, 10:40 AM
  3. Replies: 1
    Last Post: 06-12-2015, 12:03 AM
  4. Subform total on main form
    By muhammadirfanghori in forum Forms
    Replies: 1
    Last Post: 03-12-2015, 08:42 AM
  5. Replies: 19
    Last Post: 06-30-2014, 04:36 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