Results 1 to 8 of 8
  1. #1
    jree3000 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    40

    Sum of subform records currency field to main form, getting #Name? error

    I am trying to get a total amount of currency fields in a subform to show in a currency field of my main form. The subform (named "Dose_Tracker_Subform") is a datasheet. I set up a text box in the subform footer (named "subtotal") totaling the field (DosePrice) by putting the following code in the "subtotal" control source: =Sum([DosePrice])

    Then I placed the following code in the main form field that I want to display the subform total: =[Forms]![Dose_Tracker_Subform]![subtotal]

    However instead of getting a total I get a #Name? error.



    What am I doing wrong?

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    You can't refer to a subform that way - it is not part of the Forms! collection.

    Use this instead: me![subformcontainername].form![subtotal]

    where subformcontainername is the name of the control (on the main form) that contains the subform.

    John

  3. #3
    jree3000 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    40
    Hi. I don't know what you mean by the name of the control (on the main form) that contains the subform. Are you talking about the actual name of the subform? Also when I try adding that code it keeps changing it to: =[Me]![Dose_Tracker_Subform].[Form]![subtotal]

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Are you talking about the actual name of the subform?
    No. When you created your main form, you created a container for the subform - a subform/subreport control. It is the name of that subform/subreport control that you would use in place of subformcontainername in the expression.

    John

  5. #5
    jree3000 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    40
    Okay, I did that but I'm still getting #Name? error.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Can't use Me in query or textbox expression, only in VBA. Remove it and see what happens.
    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.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    How is the DosePrice populated, i.e. is this physically entered by the user or is it a calculated field?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    jree3000 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    40
    June7 does it again! I removed the "Me" portion and now it works! Thank you!

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

Similar Threads

  1. Replies: 8
    Last Post: 03-13-2013, 08:32 AM
  2. Replies: 10
    Last Post: 01-29-2013, 08:59 AM
  3. Syntax Error For Main Form Subform Report
    By burrina in forum Reports
    Replies: 1
    Last Post: 12-27-2012, 03:03 AM
  4. Replies: 0
    Last Post: 07-26-2010, 04:36 PM
  5. Replies: 4
    Last Post: 05-17-2010, 05:32 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