LinkChildfields and Masterfields for a Subreport at runtime ( VBA code)

As described in the subject I need to link Master and child fields conditionally at run time
for a Master/Sub report using the VBA code..

Thanks in advance.
LVL 6
devthaAsked:
Who is Participating?
 
GRayLConnect With a Mentor Commented:
Change:
Forms!FormName.form!sfmName.LinkMasterFields = <Enter Value>

Forms!FormName.form!sfmName.LinkChildFields = <Enter Value>

to:
Reports!ReportName.report!srptName.LinkMasterFields = <Enter Value>

Reports!ReportName.report!srptName.LinkChildFields = <Enter Value>

srptName is the subreport name
0
 
Data-ManCOOCommented:
Since the properties belong to the contain object, there is no problem doing this.  I did it on a project a long time ago.

Me.sfmContain.LinkMasterFields= "Myfield"
Me.sfmContainer.LinkChildFields= "MyOtherField"


Mike

0
 
Data-ManCOOCommented:
sorry, the subform container object should be the same name in both lines of code

sfmcontainer

Mike
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
GRayLCommented:
You have access to these values with:

Forms!FormName.form!sfmName.LinkMasterFields = <Enter Value>

Forms!FormName.form!sfmName.LinkChildFields = <Enter Value>
0
 
devthaAuthor Commented:
hello,
        I need this for REPORT.

Thanks
0
 
devthaAuthor Commented:
This would not work on ONFORMAT or ONOPEN
events.

 If Not IsNull(PrevBAC) Then
    qrySub1686OwnershipPrior.LinkMasterFields = "PrevLocPoint;PrevPlanNumber;FileDate"
    qrySub1686OwnershipPrior.LinkChildFields = "LocationPoint;PlanNumber;filedate"
 Else
    qrySub1686OwnershipPrior.LinkMasterFields = "LocationPoint;PlanNumber;filedate"
    qrySub1686OwnershipPrior.LinkChildFields = "LocationPoint;PlanNumber;filedate"
 End If
0
 
devthaAuthor Commented:
If I convert the report into a look alike FORM then, that will add to much work. If that is the only soultion I will think about going that way.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.