Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Sep 2001
    Location
    NSW, Australia
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Referring to subform on a Parent form. (Access97)

    What em I doing wrong here?

    I have a form containing number of sub forms. When I update a field in one subform I need another subform to requery in other to show various updated totals.

    In AfterUpdate even on the first subform I tried various options including:

    Tried First
    --------------
    Me.Parent!frmGrants!frmFundsTotalssubform.Requery

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Referring to subform on a Parent form. (Access97)

    The syntax for requerying one subform from another on the same form is this:

    Parent!subformcontrol.requery

    Is frmGrants the name of the parent form? If so, you don't use the form name as well as the Parent keyword, and you don't even need to include the Me keyword. Access recognizes that Parent means the object that contains this current object.
    Charlotte

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

    Re: Referring to subform on a Parent form. (Access97)

    This may seem illogical, but a subform is NOT considered an open form by Access. That is, it is NOT listed in the FORMS collection. The way to reference a subform is via the subform-control that sits on the the mainform (often this may have the same name as the subform it contains, which only makes things more confusing).

    So, let's say on my main form (frmMain) I have a control (let's call it subInvoice) which contains the subform "frmInvoice). From the mainform, I can requery the subform with either of 2 ways:

    Me.subInvoice.form.requery
    Forms!frmMain.subInvoice.form.requery

    From a subform, you can reference another subform on the same main form by going back up to the Parent:

    Me.Parent.OthersubformControlName.form.requery (for example)

    Note that you don't really need to use the Me. or the .form (as these are the default properties); however, you will find your code easier to read later.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Lounger
    Join Date
    Sep 2001
    Location
    NSW, Australia
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Referring to subform on a Parent form. (Access97)

    The following procedure is executing from a subform called frmFunds. The subform is located on the form called frmGrants. I am trying to requery another subform located on frmFunds called frmFundsTotalsSubform so it displays the updated totals. However nothing happens when I change the value in FundsAppliedFor field. Also find attached a cutdown version of the Grants database. To test it open frmGrants and change the Applied For amount under Allocated Funds header and check Total Funds amounts, then change the Granted amount and check Total Funds amounts to see the difference. Thank you very much.

    Private Sub FundsAppliedFor_AfterUpdate()
    On Error GoTo Err_FundsAppliedFor_AfterUpdate

    Parent!frmFundsTotalsSubform.Requery
    Attached Files Attached Files

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Referring to subform on a Parent form. (Access97)

    You need something like this:

    Me.Parent!frmFundsTotalsSubform.Requery

    You don't use a bang (!) between Me and Parent. Parent is a method to return a pointer to the current object's parent object, and you only use the bang when referencing a member of the form's collection of objects (i.e., controls). So, bang between Parent and subform control, but not between Me and Parent.
    Charlotte

  6. #6
    Lounger
    Join Date
    Sep 2001
    Location
    NSW, Australia
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Referring to subform on a Parent form. (Access97)

    Hi Charllote,

    Tried your suggestion and it does not work on this database. Could you check the stripdown version of the database enclude in my previous message (28/9/2001) and try to make it work. I don't see why it doesn't requery when called to do so... <img src=/S/blank.gif border=0 alt=blank width=15 height=15>

    john.fejsa@hunter.health.nsw.gov.au

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Referring to subform on a Parent form. (Access97)

    It doesn't work because you're trying too hard. All you need is this behind the subform, which will cause the other subform to requery when you save the frmFunds record. If you do it this way, there is no need for the requery in the frmFunds_Exit routine in frmGrants.

    Private Sub Form_AfterUpdate()
    Parent!frmFundsTotalssubform.Requery
    End Sub

    Until you save the frmFunds record, the data isn't there for the other subform anyhow, so there's no point in trying to requery a particular control on it in mid-record. I don't know why you were trying to set one side of the links in your procedure, but it isn't necessary because you haven't broken them that I can see.
    Charlotte

Posting Permissions

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