Link Master/Child properties

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
 
D

Danny

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top