Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Suffolk, England
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Referencing subforms (97)

    I have 2 subforms on a master form. I want to have a grand total in one of the subforms which is a sum of a figure from each of the subforms. The expression: Var1 = Me.Parent!SubFrm1!MayTotal.Value when entered in Subform2 results in Var1 = 0 (where Var1 is a public variable) UNLESS I step through the procedure. In that case, the value of MayTotal is stored to Var1.

    H E L P
    Thanks

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Referencing subforms (97)

    This is probably a timing problem, as subform2 is trying to get the information from subform1 before subform1 has had a chance to fill the textbox. When you step thru the code, subform1 has had a chance to finish.

    I'm not particularly sure how you can resolve this, other than to somehow delay subform2 to allow subform1 to catch up.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Referencing subforms (97)

    Put this code in your utility functions and then pause your subform code at the appropriate point for as long as you think necessary.

    Sub Pause(ByVal nSecond As Single)
    Dim t0 As Single
    t0 = Timer

    Do While Timer - t0 < nSecond
    Dim dummy As Integer
    dummy = DoEvents()
    ' if we cross midnight, back up one day
    If Timer < t0 Then
    t0 = t0 - 24 * 60 * 60
    End If
    Loop

    End Sub
    Peter Herworth

  4. #4
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Suffolk, England
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Referencing subforms (97)

    Thanks, that's done the trick!

    Allison

Posting Permissions

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