I want to print a sub report multiple times.
I currently have a dataset and pipeline with the correct number of records, but I would like to do it from RAP. Or is there a property of the sub report like repeat count. Or do I call a procedure from the parent band?
Lawrence
Comments
If your subreport is located inside the Detail band, try setting the ppDetailBand.BandsPerRecord property as needed in an event that fires before the band prints (OnBeforePrint).
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
In my delphi code I use the onbefore print to set the image borders for debug. (maybe I could use another event) This seems to override the RAP onbeforeprint. How can I get the RAP one to fire as well? Is there another event I could use? If I used
Perhaps I could set it in an event or code within the parent band? Before any detail band is on printed? Anu ideas?
Thanks a lot.
Even though I hook the OnBeforePrint in my delphi app, I can still hook it in RAP. I can then pick up the BandsPerRecord from my datasets and then I get the right repeats.
Does that seem reasonable?
I make the sub report that i want to repeat connected to a one record dataset and set its BandsPerRecord appropriately.
I hope that images on this band will not be loaded again during the multiple prints will not be reloaded if their data does not change,
A bit complex for me to get my head around but good to get it working. Maybe because there is no dataset iteration between prints this will be faster! Do you think?
Thanks a lot!
Correct, when both Delphi and RAP events are implemented, they will both fire in that order.
Static images (TppImage) will not load for each detail band assuming they have not been changed in the OnGetPicture event however DBImages will still be retrieved from the database and loaded.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Why is this not cleared when the oReport.Template.LoadFromFile?
I have not loaded the data or created pipelines at this stage. Is there a report.clear or something. I think this i a bug
Here is an abbreviated object dump:
object raCodeModule2: TraCodeModule
object raProgramInfo1: TraProgramInfo
raClassName = 'TraEventHandler'
raProgram.ProgramName = 'DetailBeforePrint'
raProgram.ProgramType = ttProcedure
raProgram.Source =
'procedure DetailBeforePrint;'#13#10'var'#13#10' i : integer;'#13#10'begin'#13#10' i ' +
':= prt['#39'rows'#39'];'#13#10' //showmessage('#39'i: '#39' + IntToStr(i));'#13#10' ///s' +
'howmessage('#39'Before Print:'#39')'#13#10' Detail.BandsPerRecord := i;'#13#10'end' +
';'#13#10
end
https://pastebin.com/1QQCKRzM
Its just took me a time to work out what was happening. Its just that in my program I load different reports.
I hope you can help. Thanks a lot!
Lawrence
I set the RowsPerRecord to "n", and used a 1 row dataset pipeline.
I hooked the Band.OnBeforePrint to find TppImages and load the image when the band printed.
This would always load so I got the MD5 of the larger JPG and compressed it by stretchdrawing it to a small BMP and setting the ppImage picture.
I then stored the MD5 in the (unused) image TEXT property.
Next time around I only compressed and loaded the image if it was different.
I am generating a set of labels for an number of parts with different quantities needed.
Much faster and saver than using the possibly large images.
Lawrence