Link Master/Child properties

  • Thread starter Thread starter TamiD
  • Start date Start date
T

TamiD

How do I change the Link Master/Child properties in VBA?
I need to use one set of links if the person is entering a
new record, but use a different set of links if they are
looking at a previosly entered record.

Thanks
 
One way to do this is to reference the LinkChildFields and
LinkMasterFields properties of the subform in the OnCurrent
event of either the main/master form or the subform. Like so:

For new master record:

If Me.NewRecord Then
Me.frmChild.LinkChildFields = "[ChildField_A]"
Me.frmChild.LinkMasterFields = "[MasterField_A]"
Else
Me.frmChild.LinkChildFields = "[ChildField_B]"
Me.frmChild.LinkMasterFields = "[MasterField_B]"
End If


For new child record:

If Me.NewRecord Then
Forms![frmMaster]![frmChild].LinkChildFields =
"[ChildField_A]"
Forms![frmMaster]![frmChild].LinkMasterFields =
"[MasterField_A]"
Else
Forms![frmMaster]![frmChild].LinkChildFields =
"[ChildField_B]"
Forms![frmMaster]![frmChild].LinkMasterFields =
"[MasterField_B]"
End If

Does this answer your question?

Danny
 
Back
Top