Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't update display of linked subform (2003)

    I have a main form, "Containers" with a field "ProjectNum" representing a company project number. There is a subform based on the"Projects" table linked to the amin form by a common "ProjectNum" field.

    When I change the value of Projectnum on the main field (it's a lookup to the Projects table, byt the way), the subform does not update.

    I figured it was necessary to requery the form, so I added

    ProjectSubForm.requery

    to the afterupdate event on the Project num field on the main form.

    This didn't cause an error, but didn't update the form's display either.

    So, I thought that maybe I need a refresh in there, but when I added a line:

    ProjectSubForm.refresh

    I got an error that claimed that the de###### had never heard of anything called "refresh" . Except of course, refresh is in the help files, and it's a valid method for forms. And I've used it before!



    Private Sub Combo16_AfterUpdate()
    ProjectSubform.Requery
    ProjectSubform.refresh <================Error: Method or Data member not found.
    End Sub


    Can anyone give me a clue? Help says I'm doing exactly the right thing as far as I can tell, which is not very far, because it only gives me the trivial usage example.

    Thanks

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

    Re: Can't update display of linked subform (2003)

    If you change (edit) the value of ProjectNum in the main form, two things can happen:
    <UL><LI>If you have set "Cascade Update Related Fields" for the relationship between the Containers and Projects tables, ProjectNum will be updated in the Projects table too, but only when the record in the main form has been saved. The end result is that the same records will be displayed in the subform.
    <LI>If you have not set "Cascade Update ...", the records in the subform will become orphans.[/list]Refresh is a method of a form, but ProjectSubForm refers to the subform control on the main form. To refer to the Form object in the subform control, use ProjectSubForm.Form, hence

    ProjectSubForm.Form.Refresh

    (In case you're wondering, Requery is a method of both the Form object and of Control objects)

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't update display of linked subform (2003)

    Oh for the love of pink fluffy bunnies...

    I haven't seen that one before.

    I did try to refer the the form in it's collection, something like Forms!ProjectSubForm. Wonder why that didn't work.

    It seems like Access has many ways of doing things, but most of them won't work for any particular situation.

    Thanks Hans

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

    Re: Can't update display of linked subform (2003)

    Only main forms are part of the Forms collection. Subforms can only be referred to through thier parent form.

    See Forms: Refer to Form and Subform properties and controls on the Access Web for an overview.

  5. #5
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't update display of linked subform (2003)

    That looks like a site I should be spending more time at. Thanks!

Posting Permissions

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