Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

binding subreports programatically

Status
Not open for further replies.

Kavius

Programmer
Apr 11, 2002
322
CA
Is it possible to bind a sub report programatically?

I have a report that needs to have two lists side-by-side, with a total for each at the bottom (so the totals can be compared). To do this I was thinking that I would create a sub report that listed all of the data, create two instances of it on the parent report, and put a different filter on each of the two instances.
Code:
set rpt1 = new subReport
set rpt2 = new subReport
rpt1.filter = "empnum=1"
rpt2.filter = "empnum=2"
Unfortunately, when I did this, I got an error stating:

Run-time error '2455':
You entered an expression that has an invalid reference to the property Form/Report.

Any advice would be greatly apreciated.
 
This is easiest done with 3 reports. A main report with your employees and subreports that list all data by themselves but when placed in the main report link them based on the employeeID. then when you print it you'll get the data related to each employee only. Put the totals you're looking for in the subreports and all will be well.

HTH Joe Miller
joe.miller@flotech.net
 
So you are saying to use 2 sub reports (1 for each list)?

That's the way I have it in another case, I just thought there might be a better way (less duplication).

Thanks. At least now I can feel somewhat confident that there is not necessarily a better way.
 
That IMHO is the best way because you're using all that fancy code for relationships that Microsoft built into the product. Any other way would be duplicating the effort MS already put in... Joe Miller
joe.miller@flotech.net
 
I can apply the binding without actually having the report loaded. All I would need to do is apply the filter for each (with code). Either way, I have to type in the filter and if I use only one report, every time I make a change, I only have to make it to one report.

I have already made two major changes since my last message and have had to duplicate the change on the other subreport.
 
If you make the filter in the main report and have the subreports linked properly using the parent/child links then the filter will cascade down to the subreports. You shouldn't have to apply any filter at all to the subreports if you have the links set up properly... Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top