Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Now-Luanda, Angola, Originally - Anna Bay, New South Wales, Australia
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Calculated Field on Sub form (2003 All Updates)

    I have a sub form which has data such as cost and quantity. I want to calculate the total for the individual line so have used the =Form.SubFormname.fieldname process eg multiply the quantity by the costs with mixed results
    When I open the subform (which gets its info from a table not a query in case thats important), everything works fine. When I open the parent form I get NAME? instead of the calculated result in the subform
    I tried adding the parent form and subform names as the source to ensure the full "path" was there eg =Form.parentformname.subformname.fieldname but got nowhere.
    What am I doing wrong
    Steve
    Dummy from Down Under <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Calculated Field on Sub form (2003 All Updates)

    Use an expression like this:

    =[Subformname]![Controlname]

    or

    =[Subformname].[Form]![Controlname]

    where Subformname is the name of the subform as a control on the main form. This is not necessarily the same as the name of the subform in the database window. To see the control name, open the main form in design view and click once on the subform. The control name will be displayed in the title bar of the Properties window.

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Calculated Field on Sub form (2003 All Updates

    You can't use the =Form.SubFormname.fieldname syntax when the form is open as a subform.
    You either need to use the full syntax you tried , or just the simpler one that just uses field names.
    e.g. [Quantity]*[Price]

    Or perform the calculation in a query, and bind the control to the calculated field from the query.
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •