Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jun 2004
    Location
    Itasca, Illinois, USA
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Refresh data in subform (Access)

    I have a form with two subforms. They are all linked by the customer's policy number and premium year. When I change a value in the first sub form, the second subform does not refresh. In order to get all the forms refreshed I have to go to the top of the form and reselect the premium year. Then the numbers refresh. Is there a neater way to refresh?

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

    Re: Refresh data in subform (Access)

    Is the second subform
    (1) a subform of the main form, or
    (2) a subform of the first subform?

    If (1), how is the second subform linked to the first one, in other words how should "change a value in the first sub form" influence the second subform? Pleas provide some details.

    If (2), the updating should be automatic, if the master and child link fields have been set up correctly.

  3. #3
    New Lounger
    Join Date
    Jun 2004
    Location
    Itasca, Illinois, USA
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Refresh data in subform (Access)

    Both subforms are subforms only to the main form. Both have the same link to the form. When I enter data I run a macro to update the forms. The first subform is refreshed, but the second subform does not refresh. Does this help. Here's more, when I change the payroll in the first subform, and press the calculate button, a macro recalculates the premium. The total of all premiums is listed down in the second subform. The first subform shows the new calculated premium, but the bottom subform does not refresh the sum of all premiums. Thank you.

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

    Re: Refresh data in subform (Access)

    First of all, you need to understand the difference between the terms "refresh" and "requery"; they are distinctly different. When you refresh a form, Access gets the latest information for the records that are already in the recordset behind the form; it doesn't rerun the original in your form's recordsource, so it won't find new records. By contrast, a Requery reruns the query in the recordsource.

    You will need to tell Access to requery the 2nd subform. Let's assume this 2nd subform is named [sub2]; that is, this is the name of the subform control that sits on the main form (and may or may not be the name of the form contained by the subform). From the first subform, all you need is a single line of code the in click event of your Calculate button:
    Me.Parent.sub2.Requery
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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