Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How To Execute a Sub In Form From a Subform? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I have a from with a subform

    The form has a module with the following subroutine

    Private Sub CalculateTotals()
    .
    .
    End Sub

    This subroutine calculates totals in the from into unbound controls.

    Is there a way in the subform On Current event to call CalculateTotals (in main form) to refresh the totals on the main form?

    Thanks, John

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

    Re: How To Execute a Sub In Form From a Subform? (a2k (9.0.6926) SP-3 Jet

    You would have to change the definition of CalculateTotals from Private to Public. "Private" means that the definition on that line is available ONLY within the module that contains the definition; other modules cannot use it. "Public" means that the definition is available to other modules.

    You can then call CalculateTotals as follows from the subform:

    Me.Parent.CalculateTotals

    Me refers to the subform.
    Me.Parent refers to the parent of the subform, i.e. the main form.

    Provided that the main form is loaded, you could also call CalculateTotals from another form or module as

    Forms("NameOfMainForm").CalculateTotals

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How To Execute a Sub In Form From a Subform? (a2k (9.0.6926) SP-3 Jet

    Fantastic

    I had to include the following because the record source was not set when the sub form is loaded.

    <pre>If Not IsNull(Me.Parent.idsKeyOfSumServe) Then
    Me.Parent.CalculateTotals
    End If
    </pre>


    Thanks, 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
  •