Multiple RecordSets in reports

Hi! As far as my understanding, you do a report(recordset, printer) so you can print what desired. However I need to print multiple sql statements for different fields. Some have only 1 row and others multiple rows. Any idea how to achieve that?

Hi Adrian, are you using the built-in report engine?

I have an app that needs to do that also. My solution was to create an in-memory database and populate it with just the various data needed for the report. Then I queried the in-memory database and sent that recordset to the report generator.

Yes I am

That’s great. Do you work with a single row or something like that? What I don’t get here is that a report field gathers info from a field in the recordset. So, if there are multiple rows in the same field, it prints all of them. But what if I only need to print one row? E.g. I have two tables related by a key. When my in-memory database is populated, multiple rows will have the same key in the same field. So if one report field is assigned to that record field, is it going to print the same key multiple times? (Maybe Im really wrong here hehe)

Yes, the report should print all the rows of data in the RecordSet you send it. So the in-memory database should be populated with the just data you want to print in the report.

I generally create and populate the in-memory database’s tables on the fly for the report I’m generating. Then I drop the tables when the report is done so that it can be ready for the next report (which may be for a totally different report form).

You can do the same thing using a temporary table in the main database but if you’re dealing with a lot of data an in-memory database is often faster.

If you want to fill a report field with values that aren’t in the recordset you pass to the report, you can write the code in the BeforePrinting event of that field. You can use every class or module you have in your project, just as you do in a window.
Hope this helps you.