Reference subform on a Tab control

  • I have a form that has a Tab Control with 10 tabs. Each tab has a subform. I am dynamically creating these forms from template forms I have. I make a copy of the main form and 10 subforms that are in each tab. I want to be able to rename the sourceobject of each subform in each tab. I tried renaming the sourceobject and Name of the subform from the main form, but It is not working. I think I need to put the Tab control name somewhere in here but not sure where?

    MyFormName = The name of the main form

    MyTemplateName = The current name of the subform

    mysubformsNew = The New name of the subform I want to give to the subform

    'The name of my Tab Control is "TabMain"

    'This is what I am trying

    Forms(MyFormName).Controls(MyTemplateName).Form.SourceObject = MySubFormsNew

    Forms(MyFormName).Controls(MyTemplateName).Form.Name = MySubFormsNew

  • I found the correct syntax:

    Forms(MyFormName).Controls(MyTemplateName).SourceObject = MySubFormsNew

    Forms(MyFormName).Controls(MyTemplateName).Name = MySubFormsNew

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply