Since I’ve gone back to programming, more things on this blog have been to help me remember what I did! This is one of the programming posts, music will be on my next entry, I promise!
More Developer’s Express fun… I both love and hate some of the things that DevExpress does with their tools. I’ve recently started using the XtraReports suite for some ‘more than trivial’ reports, and hit a snag. I had a devil of a time trying to solve this issue, it took almost a day to figure out a way to make this work.
Here’s the setup:
I had a report that had three different sets of data. The exact information is a Point of Sale daily report, needing sales, taxes, and payments, but that’s not pertinent to the problem here… To use the three disparate data sources, I started off using three sub reports with a master report that would only have one record. This worked grand! I was able to do the reports with no problem… but… I needed to have a total of all three sub reports. This is where my implementation came crashing down. The XtraReports sub reports have a great way to send information to the sub report, but it doesn’t have a very good way to get the information BACK to the original report. I tried everything I could think of for almost a day, but with no luck in using the sub reports.
After reading a LOT of pages and articles, I found out that the XtraReports had a very neat feature. The reports have what DevExpress calls a ‘DetailReportBand’ on a report. This allows you to have a fully nested sub report inside of the main report without it being an actual sub report in a completely separate report. Hmmm… combine this with the parameters feature, and I may have something… It was easy enough to move the sub reports into Detail Report Bands, and it actually simplified the code a bit. Hoo-rah! I still had to get the running total, though.
After a couple of false starts, I did get the running total working. To get this to work, a report parameter needs to be added to the report. Then, the easiest way that I found to get the subtotals into the parameter was to use the sub report’s summary total XrLabel’s SummaryCalculated event to add the amount to the parameter. Then, at the end, it was straight forward to set a label to the parameter to show the overall total.
I know this blog post may not make a lot of sense to most, but it will help me in the future when I have to do this again, and can’t remember what I did!