Form Emulation is the process of taking a paper-based or electronic form and rendering a likeness of it. The likeness may include formatting of the form itself, or may only contain the data which will ‘fill-out’ the form. There are two basic issues that a form emulation solution must resolve:
- How will the formatting of the form be generated?
- How will the data which ‘fills-out’ the form be generated?
The first issue is resolved by using either a page-sized band within the report or by utilizing a page style. A page style can be designed just like a band, but generate as a background to the bands of the report.
The second issue is resolved by using either simple data-aware components or by using more complex region or subreport components.
In ReportBuilder, there are several approaches that achieve form emulation. These approaches are discussed in detail in this section.
Single Page Forms
Single page forms can be emulated in several ways using ReportBuilder. Some common approaches are as follows:
- Expand the detail band to the printable height of the page, hide the header and footer band, and place all form formatting and data-aware controls in the detail band. This approach yields one form per record. The following diagram shows an entire form in the detail band.
- Add a page style to the report. Place all formatting for the form in the page style. Layout the data-aware controls as you would when building a normal report. This approach yields a variable number of records per form, depending on the height of the bands. In this approach, the detail band is used to ‘fill-out’ the form. The following diagram shows how a detail band can ‘fill-out’ a page style.
- Expand the detail band to the printable height of the page. Hide the header and footer band, and place all form formatting in the detail band. Place child-type subreports in different areas of the form where a table or particular source of data is needed to fill out that part of the form. Place data-aware components in areas of the form where the master datapipeline supplies the data. This action yields the most flexible and powerful form emulation solution, but is only needed when multiple data sources are used. The following diagram shows subreports filling out a form in the detail band.
The form itself may be too complex to recreate using report components. In this case it is recommended that you scan the form and convert it to a windows metafile. You can then place the windows metafile in the report as either a ‘background’ for the detail band or in the page style, where it will function naturally as a background for the report.
When you have a form in a WMF image, the end-user gets an excellent print preview capability. If you are printing on pre-printed forms, you can set the visible property to false when the report is sent to the printer. In this way you can provide a filled-out form in the print preview window, but only the text necessary to ‘fill-out’ the form is actually sent to the printer.
All of the approaches discussed in the single page form topic are applicable to the multi-page forms. The additional problem of organizing single-page forms into sets of multi-page forms can be resolved using section style subreports. When Section-style subreports are rendered, they generate a new page within the parent report, continue generating pages until all data has been traversed (or they are stopped manually through a procedure call to the report engine), and then return control to the parent report. One special behavior of section-type subreports is that the parent report generates no pages when the section is placed in a dynamic-height detail band. In this case, the main report is used as a launching pad for one to many sections. Since each section is a full-fledged report in its own right, all of the single page form approaches can apply to each section, thus creating a multi-page form solution.
The diagram below shows three section-type subreports in the detail band of the main report. The main report is assigned to a data pipeline, so the detail band will print once for each record. The subreports contain data-aware controls that point at this data pipeline. After the detail band of the subreports prints, the DataTraversalComplete method of the report is called, manually stopping the report. This report provides three pages of content for each record, and each page has its own unique format.