by A.D. Tejpal
This sample db demonstrates printing of multiple reports with dynamic assignment of caption via report's open event. The user can alter the sequence of printing as desired, by moving the report names up or down. Out of available reports, those required to be included in sequential printing are selected by ticking the check box adjacent to report name.
It is observed that if a report is printed directly by opening in normal view, the caption assigned programmatically in report's open event does not get properly captured in the print queue of the printer. This is explained by the fact that caption of active window tends to get captured for the above purpose. Depending upon the local set up, direct opening of report might not project its window presence adequately. For absolute certainty, it is therefore necessary that the report is first opened in preview mode, followed by PrintOut and Close actions.
It would be interesting to note that you can't get away by opting for preview in hidden mode. In that case, you might even end up with the caption of the calling form getting depicted in print queue. The defining requirement is that the report should be the visible active window (even if for a very brief duration) when requisite information is getting passed to the printer.
Time delay (in clock cycles) as included between various stages (e.g. opening in preview mode, print out and closing), as a measure of abundant precaution, is meant for stabilization between one step and the next.
You can find the sample here: