Good morning, all. Long time no post.
I am helping a coworker with a project. He needs to change the linking
fields of a subform in code. The problem is that in certain circumstances,
there will be one field to link the form/subform and in other fields there
will be two fields.
What happens is:
If the link is set to two fields and we try to change it to link on one,
when we change the first link (either the LinkChildFields or
LinkMasterFields property) then the number of fields don't match, and we
get an error.
How do I get around this problem?
Here is the code:
****BEGIN CODE****
If Me.OpenArgs = 0 Then
Me!txtLastName.Visible = True
Me![FromOffice].Visible = False
Me!FromCustId.Visible = False
Me!FromAccount.Visible = False
Me![frmShowRecordsSubForm].LinkChildFields = "lastname"
Me![frmShowRecordsSubForm].LinkMasterFields = "lastname"
ElseIf Me.OpenArgs = 1 Then
Me![FromOffice].Visible = True
Me!txtLastName.Visible = False
Me!FromAccount.Visible = False
Me!FromCustId.Visible = True
Me![frmShowRecordsSubForm].LinkChildFields = "fromoffice;fromcustid" 'ERROR HERE
Me![frmShowRecordsSubForm].LinkMasterFields = "fromoffice;fromcustid"
Else
Me![FromOffice].Visible = True
Me!txtLastName.Visible = False
Me!FromAccount.Visible = True
Me!FromCustId.Visible = False
Me![frmShowRecordsSubForm].LinkChildFields = "fromoffice;fromaccount"
Me![frmShowRecordsSubForm].LinkMasterFields = "fromoffice;fromaccount"
end if
****END CODE
Thanks for any input, ideas, references.
Kathryn
I am helping a coworker with a project. He needs to change the linking
fields of a subform in code. The problem is that in certain circumstances,
there will be one field to link the form/subform and in other fields there
will be two fields.
What happens is:
If the link is set to two fields and we try to change it to link on one,
when we change the first link (either the LinkChildFields or
LinkMasterFields property) then the number of fields don't match, and we
get an error.
How do I get around this problem?
Here is the code:
****BEGIN CODE****
If Me.OpenArgs = 0 Then
Me!txtLastName.Visible = True
Me![FromOffice].Visible = False
Me!FromCustId.Visible = False
Me!FromAccount.Visible = False
Me![frmShowRecordsSubForm].LinkChildFields = "lastname"
Me![frmShowRecordsSubForm].LinkMasterFields = "lastname"
ElseIf Me.OpenArgs = 1 Then
Me![FromOffice].Visible = True
Me!txtLastName.Visible = False
Me!FromAccount.Visible = False
Me!FromCustId.Visible = True
Me![frmShowRecordsSubForm].LinkChildFields = "fromoffice;fromcustid" 'ERROR HERE
Me![frmShowRecordsSubForm].LinkMasterFields = "fromoffice;fromcustid"
Else
Me![FromOffice].Visible = True
Me!txtLastName.Visible = False
Me!FromAccount.Visible = True
Me!FromCustId.Visible = False
Me![frmShowRecordsSubForm].LinkChildFields = "fromoffice;fromaccount"
Me![frmShowRecordsSubForm].LinkMasterFields = "fromoffice;fromaccount"
end if
****END CODE
Thanks for any input, ideas, references.
Kathryn