Access run code in SubReport while opening main report

Hi

I have VBA code to populate a ListBox in an Access subreport . I an trying to run
the code  in this SubReport but getting the error shown below. The main report is called "rptInvoice"

1
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor Infotrakker SoftwareCommented:
Also, as I mentioned in your earlier question, you cannot directly refer to a Subreport (or Subform), since it's not a member of the Reports collection. You instead have to refer to the Parent report first, then go from there. The syntax is like this:

Reports!ParentReport.SubReportCONTROLName.Report.SomePropertyOrMethod

ParentReport is the main report (the "parent")

SubReportCONTROLName is the name of the Subcontrol report on the parent report. It may or may not be named the same as the report you're using as a subreport.

For example, If my parent report is named rCustomer and my subreportCONTROL is name srpLocations (which uses a report named rLocations as the subreport):

Reports!rCustomer.srpLocations.Report.CalculateValue

This would run a method named CalculateValue on the report name rLocations, which is being hosted in a subreport control name srpLocations.

Confused yet :) ?
0
 
Gustav BrockConnect With a Mentor CIOCommented:
Have in mind, that first the subreport opens, then closes, then the main report opens, and finally the subreport opens again.
That can cause some issues.

Also, oPopulate_ListBox must be declared Public.
0
 
ste5anSenior DeveloperCommented:
Just a comment: What's the use of a ListBox in a report?

I prefer just querying the data already in the data source itself.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Hi Ste5an. The ListBox is there for the [Invoice Detail]. The rest of the form is there for the [Invoice] table
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
The ListBox is there for the [Invoice Detail]
That's generally done with a standard Subreport instead of a Listbox on a Subreport.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks Scott
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.