Results 1 to 4 of 4
  1. #1
    JamesP
    Guest

    Switching out subforms

    Hi

    I have been attempting to use a unbound subform space to use with dirrerent subforms depending on what button I push. I found this code from a book to switch out subforms " Me!subview.SourceObject = FormName". The code seems to not work.
    Is there another way?
    Is it possible?

    Thanks again!

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

    Re: Switching out subforms

    If subview is the name of your subform control and frmSubform is the name of an existing form on your machine, then this expression should work:
    <pre> Me!subview.SourceObject = "frmSubform"</pre>


    You may need additional code to set the links between the parent form and the subform.

    <pre> Me!subview.LinkChildFields = "KeyID"
    Me!subview.LinkMasterFields = "KeyID"</pre>


    Where KeyID represents the name of the linking field in each recordset.
    Charlotte

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Switching out subforms

    I use code like

    Dim sbForm As SubForm
    Set sbForm = Me![General SubFrm]

    Select Case Me!X
    Case 0
    sbForm.SourceObject = "XXXX"


    However I don't see any obvious difference between your sample code and this from me.

  4. #4
    JamesP
    Guest

    Re: Switching out subforms

    Thanks Charlotte and Andy

    I got it now!
    [img]/w3timages/icons/blush.gif[/img]

Posting Permissions

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