Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Apr 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Accessing fields from a subform (2003)

    Hi

    I am having trouble getting a subtotal from a subform on a tab control onto another subform. My forms are as follows.
    Main form
    Data (PatientId)
    SubformA
    Data (PatientId, AdmissionDate, DischargeDate)

    Tab1
    SubformB
    Data (PatientId, AdmissionDate, ServiceItem, ServiceAmount)
    Tab2
    SubformC
    Data (PatientId, AdmissionDate, PathologyItem, PathologyAmount)

    I have created a subtotal SumServiceAmount on SubformB and I want to access it from SubformA so I can store the total amount with the admission data. No matter what I try the text box on SubformA just shows ?Name. I hope someone can offer a suggestion.

    Thanks

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Accessing fields from a subform (2003)

    I think you're going to have trouble doing things in that fashion. I presume you are trying to make the textbox on SubformA a bound control, and therein lies the problem. In general, what you are attempting to do is store a calcuated value in a table, and that is not considered a normal form. There are circumstances where it is desirable to store a calculated value in a field for historical purposes, but generally it isn't recommended. More than likely what you will need to do is use VBA code and set the value on the form after your SubformB has been loaded and the SumServiceAmount has been calculated. The other option would be to create a Totals (GroupBy) query that calculates the sum for you, but that duplicates lots of the subformB function, and would not be an updateable query. Hope this gives you some guidance.
    Wendell

  3. #3
    New Lounger
    Join Date
    Apr 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing fields from a subform (2003)

    Wendel

    Thanks for the advice. I reconsidered what I was trying to do, made some changes to my design and the whole thing is much more straight forward now. Sometimes we dig deep holes for ourselves by trying to solve the immediate problem rather than searching for the cause.

    Thanks for pointing me in the right direction.

    Fearless

Posting Permissions

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