Is it possible to have a bill of materials report like the BOM_Qty (With IDs) report, but with the device tags listed in a single line?
This article answers the question above as a demonstration of some of the possibilities of BeforePrint scripting and report template functionality. It will describe the process of modifying the BOM_Qty (With IDs) template to achieve the goal of having the device IDs in a single line for each part number. A template modified as described in this article is available here.
private void GroupHeader1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { devicetags = ""; // reset devicetags }
In this template, the group header band is generated for each part number. For each group header, the detail band receives a row of data for each device to which the part number is assigned. To make the device tags appear in a single line, or row, they must be stored as they are received one-by-one and then displayed later, concatenated.
private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { if (GetCurrentColumnValue("DeviceTag") != DBNull.Value) if (devicetags == "") // if devicetags is empty, set it equal to the DeviceTag value devicetags = (string)GetCurrentColumnValue("DeviceTag"); else // if devicetags is not empty, append the current DeviceTag value to it with a comma devicetags = devicetags + ", " + (string)GetCurrentColumnValue("DeviceTag"); }
Since the device tag data was gathered in the Detail band, it must be displayed in a subsequent band. So the table in the GroupHeader1 band must be moved to the GroupFooter1 band.
private void tableCell2_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { (sender as XRLabel).Text = devicetags; }
The completed BOM_Qty Inline IDs template
Before Print scripts for report templates