• Refresh data in subform (Access)

    Author
    Topic
    #406598

    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?

    Viewing 1 reply thread
    Author
    Replies
    • #844378

      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.

      • #844398

        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.

        • #844450

          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

        • #844451

          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

      • #844399

        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.

    • #844379

      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.

    Viewing 1 reply thread
    Reply To: Refresh data in subform (Access)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: