LinkMasterfields/Childfields property - Example?

G

george

Hi to everybody,

Could someone please give me an example on the
LinkMasterfields/Chieldfields property, because the Access
help doesn't provide one.

My main form, frmMain, contains a TabControl with a
subform on it, fsubSubform.

There are 3 combo boxes on the main form whose value will
be linked with the corresponding 3 textboxes on the
subform.

The 3 combo boxes are cbo1, cbo2, cbo3 and the 3 textboxes
are txt1, txt2, txt3. In order to link *programmatically*
the three pairs what do I do?

I have used something along the lines:
fsubSubform.LinkMasterFields _
cbo1.value;cbo2.value;cbo3.value

fsubChooseSubform.LinkChildFields txt1;txt2;txt3

but of course this is wrong syntax. Can someone please
help me to get it right?

thanks a lot in advance, george
 
S

Sandra Daigle

The LinkChildFields and LinkMasterFields properties are text properties
which hold a string containing just the name of the appropriate fields.

me.fsubSubform.LinkMasterFields = "cbo,cbo2,cbo3"
me.fsubSubform.LinkChildFields="txt1,txt2,txt3"

This could also be written using the 'With..End With' construct:

With me.fsubSubform
.LinkMasterFields = "cbo,cbo2,cbo3"
.LinkChildFields="txt1,txt2,txt3"
End With

Note that in LinkMasterFields you can refer to the names of controls or
fields but in LinkChildFields you must refer to the names of fields (in the
underlying recordset).

Also note that in the above code "fsubSubform" must be the name of the
subform control on the main form.
 
G

george

Thanks a lot Sandra, it works great!
george

-----Original Message-----
The LinkChildFields and LinkMasterFields properties are text properties
which hold a string containing just the name of the appropriate fields.

me.fsubSubform.LinkMasterFields = "cbo,cbo2,cbo3"
me.fsubSubform.LinkChildFields="txt1,txt2,txt3"

This could also be written using the 'With..End With' construct:

With me.fsubSubform
.LinkMasterFields = "cbo,cbo2,cbo3"
.LinkChildFields="txt1,txt2,txt3"
End With

Note that in LinkMasterFields you can refer to the names of controls or
fields but in LinkChildFields you must refer to the names of fields (in the
underlying recordset).

Also note that in the above code "fsubSubform" must be the name of the
subform control on the main form.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi to everybody,

Could someone please give me an example on the
LinkMasterfields/Chieldfields property, because the Access
help doesn't provide one.

My main form, frmMain, contains a TabControl with a
subform on it, fsubSubform.

There are 3 combo boxes on the main form whose value will
be linked with the corresponding 3 textboxes on the
subform.

The 3 combo boxes are cbo1, cbo2, cbo3 and the 3 textboxes
are txt1, txt2, txt3. In order to link *programmatically*
the three pairs what do I do?

I have used something along the lines:
fsubSubform.LinkMasterFields _
cbo1.value;cbo2.value;cbo3.value

fsubChooseSubform.LinkChildFields txt1;txt2;txt3

but of course this is wrong syntax. Can someone please
help me to get it right?

thanks a lot in advance, george


.
 

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