Replace Subform

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    #1

    Replace Subform

    Hi Guru's,
    What I am trying to achieve is a main form with buttons down the left
    side and the rest of the form filled with a sub form. When one of the
    buttons is clicked, the sub form with be populated with a corresponding
    form. What I think is needed is to update the source object of the subform
    but I have no clue on how to do this! Any offers?

    TIA,

    Mark


  • Rog

    #2
    Re: Replace Subform

    One way of doing this is putting all your subforms on top of each
    other, make them hidden (set the visible property to no), then make one
    of them visible, and the others hidden, when one of the buttons is
    clicked. In the OnClick event of the button you would have
    Me!Subform1.Vis ible = True
    Me!Subform2.Vis ible = False
    Me!Subform3.Vis ible = False, etc.

    Comment

    • BillCo

      #3
      Re: Replace Subform

      If your relationships are clearly defined then you can simply change
      the subform in code and you dont even have to worry about Master /
      child link fields. This code works fine for me:

      me.myChildContr olName.ObjectSo urce = "myNewFormN ame"
      me.myChildContr olName.Requery

      If you dont have defined relationships between the underlying tables /
      queries in the forms, then you may have to set the Master and Child
      Link fields...

      me.myChildContr olName.LinkMast erFields = "Ref Key"
      me.myChildContr olName.LinkChil dFields = "Foreign Key"

      Another approach might be to use tabs instead of buttons with a subform
      in each tab Or as Rog suggested, hiding and making visible various
      subforms - but remember: the more subforms you have open at once, the
      slower your form will be.

      Comment

      • Mark

        #4
        Re: Replace Subform

        Thanx for your suggestions. I managed to achieve what I wanted with
        Me.SubFormName. SourceObject = "Form_Name"

        Thanks again,

        Mark

        "BillCo" <coleman.bill@g mail.com> wrote in message
        news:1121327246 .810459.21690@g 14g2000cwa.goog legroups.com...
        If your relationships are clearly defined then you can simply change
        the subform in code and you dont even have to worry about Master /
        child link fields. This code works fine for me:

        me.myChildContr olName.ObjectSo urce = "myNewFormN ame"
        me.myChildContr olName.Requery

        If you dont have defined relationships between the underlying tables /
        queries in the forms, then you may have to set the Master and Child
        Link fields...

        me.myChildContr olName.LinkMast erFields = "Ref Key"
        me.myChildContr olName.LinkChil dFields = "Foreign Key"

        Another approach might be to use tabs instead of buttons with a subform
        in each tab Or as Rog suggested, hiding and making visible various
        subforms - but remember: the more subforms you have open at once, the
        slower your form will be.


        Comment

        Working...