dbTalk Databases Forums  

Access 2003 Parent-Child relation between two forms

comp.databases.ms-access comp.databases.ms-access


Discuss Access 2003 Parent-Child relation between two forms in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Arsene@selenium.net
 
Posts: n/a

Default Access 2003 Parent-Child relation between two forms - 04-08-2011 , 09:47 AM






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

Reply With Quote
  #2  
Old   
James A. Fortune
 
Posts: n/a

Default Re: Access 2003 Parent-Child relation between two forms - 04-08-2011 , 12:17 PM






On Apr 8, 10:47*am, Ars... (AT) selenium (DOT) net wrote:
Quote:
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

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Access 2003 Parent-Child relation between two forms - 04-09-2011 , 03:21 AM



On 08/04/2011 18:17:16, "James A. Fortune" wrote:
Quote:
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

Reply With Quote
  #4  
Old   
Arsene@selenium.net
 
Posts: n/a

Default Re: Access 2003 Parent-Child relation between two forms - 04-09-2011 , 09:46 AM



On Sat, 9 Apr 2011 09:21:09 +0100, "Phil" <phil (AT) stantonfamily (DOT) co.uk>
wrote:

Quote:
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
Thank you both James and Phil very much for your advice.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.