At times, a report is expected to display different information in different conditions known only at run time. For example:
If an end-user runs the report, display login time, logout time and duration in minutes for the user.
If an administrator runs the report, display login time, logout time, duration in minutes and data transfer (in MB) for all the users that administrator is managing.
Such tasks can be achieved through use of frame control and scripting.
Figure 1: Detail section has three frames that are displayed conditionally
A frame control basically “holds” multiple controls. Depending on the need, you can change its properties at run time through scripting and that way affecting all the controls on the frame.
Placing the Frame control on canvas
Frame control can be placed on any of the report sections. To place frame control on report canvas,
- From Insert menu, click Frame
- Click tool button.
Mouse pointer turns to a cross-hair. Point to the top left corner of the area you want to cover in frame and drag it to bottom-right corner.
Figure 2: Placement of Frame control
Properties pane will display default properties of the selected frame control, which you can change if desired.
To place field controls on a frame, drag corresponding fields from Fields list to the Frame on canvas.
Figure 3: Three fields and one Label placed on frame
Following controls can be placed on frame:
Following controls cannot be placed on frame:
- Page break
- Sub report
You can set individual properties of controls placed on frame by selecting a control and changing properties from Properties pane.
Frame and Scripting
When you place multiple controls on a frame, you can manage all the controls (like its visibility) at one go.
Using scripting, you can display or hide a frame dynamically at run time.
For example, for a report, you need to:
- If for parameter UserType, user specifies “A”, display Product ID, Product Name and Sales_92 in detail section.
- If for parameter UserType, user specifies “B”, display Product type, and it should display Product Name, Sales_92 and Sales 93.
To achieve this, you will,
- Create a character type parameter UserType.
- In detail section, place a frame control A and place fields Product ID, Product Name and Sales_92 on it.
- In detail section, place a frame control B and place fields Product Name, Sales_92 and Sales 93 on it.
- Select Detail Section and on its On Format event, write script to
- Set Visible property of Frame A as False.
- Set visible property of Frame B as False.
- Check the value of parameter UserType:
- if value is “A” set Visible property of Frame A as True.
- if value is “B” set Visible property of Frame B as True.
When report is executed, Input Parameter Form will appear, where user will provide parameter value. If user has entered “A”, Frame A will be displayed in the report. If user has entered “B”, Frame B will be displayed in the report.