![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Does anyone know if (without depending on a reference to an auxiliary textbox in a mainform) there is a way to establish a parent-child relation between two subforms sitting side-by-side inside the same mainform? Thanks |
#3
| |||
| |||
|
|
On Apr 8, 10:47*am, Ars... (AT) selenium (DOT) net wrote: Does anyone know if (without depending on a reference to an auxiliary textbox in a mainform) there is a way to establish a parent-child relation between two subforms sitting side-by-side inside the same mainform? Thanks I like the generality I get by setting the RecordSource property dynamically rather than using the convenient automatic link fields. Here's an example: MainForm code: Public Sub RequerySubform2(strID As String) 'Subform2 starts out with .Visible = False to keep the new RecordSource from running when frmMain opens If Subform2.Visible = False Then Subform2.Visible = True Exit Sub End If Subform2.Form.RecordSource = "SELECT * FROM tblItems WHERE ID = " & strID & " ORDER BY IdItem;" Subform2.Form.Refresh Subform2.Form.Repaint End Sub Subform1 code: Private Sub Form_Current() If Not IsNull(Me.ID) Then Call Form_frmMain.RequerySubform2(CStr(Me.ID)) End If End Sub When a record is selected on the "parent" subform, the related records are shown on the second subform. James A. Fortune CDAMPoster (AT) FortuneJames (DOT) com |
#4
| |||
| |||
|
|
On 08/04/2011 18:17:16, "James A. Fortune" wrote: On Apr 8, 10:47*am, Ars... (AT) selenium (DOT) net wrote: Does anyone know if (without depending on a reference to an auxiliary textbox in a mainform) there is a way to establish a parent-child relation between two subforms sitting side-by-side inside the same mainform? Thanks I like the generality I get by setting the RecordSource property dynamically rather than using the convenient automatic link fields. Here's an example: MainForm code: Public Sub RequerySubform2(strID As String) 'Subform2 starts out with .Visible = False to keep the new RecordSource from running when frmMain opens If Subform2.Visible = False Then Subform2.Visible = True Exit Sub End If Subform2.Form.RecordSource = "SELECT * FROM tblItems WHERE ID = " & strID & " ORDER BY IdItem;" Subform2.Form.Refresh Subform2.Form.Repaint End Sub Subform1 code: Private Sub Form_Current() If Not IsNull(Me.ID) Then Call Form_frmMain.RequerySubform2(CStr(Me.ID)) End If End Sub When a record is selected on the "parent" subform, the related records are shown on the second subform. James A. Fortune CDAMPoster (AT) FortuneJames (DOT) com Mainform Key MyID Subform1 LinkMasterField: MyID LinkChildField: AnotherID Subform2 LinkMasterField: Subform1.Form!AnotherID LinkChildField: ThirdID This assumes that there are suitable relationships established Phil |
![]() |
| Thread Tools | |
| Display Modes | |
| |