Search code examples
formsvbams-accessms-access-2007ms-access-2010

MS Access duplicated subforms on the tab


In Ms Access I have two tables (Table1, Table2) and two subforms (Table1_Subform, Table2_Subform) based on that tables. (see example in attached file: http://ge.tt/6S1rQlw/v/0) Next I have some main form "MasterForm" which has three tabs (PageBoth, Page1, Page2), Page1 contains Table1_Subform and Page2 contains Table2_Subform.

I need to have same both those subforms on "PageBoth" tab, is it possible to do somehow programatically? I need something like

PageBoth.Controls.Add(Table1_Subform)
PageBoth.Controls.Add(Table2_Subform)

and those subforms should appear on "PageBoth" tab. Or it's impossible?

I can drop new instances of those subforms to "PageBoth", but in that case I will need to implement same logic for both subforms in VBA code.

Appreciate any help. Thanks


Solution

  • This works as follow:

    In MasterForm, you add two subforms named frmInputBoth1 and frmInputBoth2 on PageBoth:

    Private Sub Form_Open(Cancel As Integer)
    '
      Me.frmInputBoth1.SourceObject = "Table1_Subform"
      Me.frmInputBoth2.SourceObject = "Table2_Subform"
    '
    End Sub
    

    On Page1 you have subform contorl frmInput1 with Table1_Subform as subform SourceObject. On Page2 you have subform contorl frmInput2 with Table2_Subform as subform SourceObject.

    In this case you have a risk of multi-user simutaneous access error if you modify data.