Reports can be saved and loaded into the designer by a variety of different methods. The easiest method is to use the File menu on the designer to Save or Open RPX files (ActiveReport's standard XML-formatted report files).
To save the report created in the previous sample:
Stop the project and restart is so the designer will return to the default setting. To load the previously created report back into the designer:
When the RPX file is loaded, the designer will display the previously created report.
A designer's layout can be saved and loaded through code by using the following methods:
Saving:
To save a designer layout in code use the designer's SaveToObject method to save the layout to a report object. Once the layout is saved to the report object, the report object's SaveLayout method can be used to save the layout to an RPX file, or byte array. Add the following code to the sample project to save the designer layout whenever the Report Preview tab is selected.
Private Sub prepPreview()
On Error GoTo errHndl
'Writes the designer's layout
'to the report so it can be previewed.
ard.SaveToObject rpt
'Saves the report object to the specified style
rpt.SaveLayout App.Path & "\sample report.rpx", ddSOFile
'Resets report
rpt.Restart
'Run the new report
rpt.Run False
'Add the report to the veiwer
Set arv.ReportSource = rpt
Exit Sub
errHndl:
MsgBox "Error Previewing the Report: " & Err.Number & " " & Err.Description
End Sub
Save these changes.
Loading:
To load a designer layout in code use the report object's Load method to load a specified RPX file and the designer's LoadFromObject to read the layout into the designer. Add the following code to the project to load the report designer when the project starts, and whenever the Runtime Designer tab is selected.
Private Sub Form_Load()
'Set active Tab to the designer
SSTab1.Tab = 0
Set rpt = New ActiveReport
'Activate all the toolbars
ard.ToolbarsVisible = ddTBToolBox + ddTBAlignment + ddTBExplorer + _
ddTBFields + ddTBFormat + ddTBMenu + ddTBPropertyToolbox + ddTBStandard
ard.ToolbarsAccessible = ddTBToolBox + ddTBAlignment + ddTBExplorer + _
ddTBFields + ddTBFormat + ddTBMenu + ddTBPropertyToolbox + ddTBStandard
'Load the saved RPX file into a report object
rpt.LoadLayout App.Path & "\sample report.rpx"
'Load the report object into the designer
ard.LoadFromObject rpt
End Sub
Private Sub prepDesigner()
On Error GoTo errHndl
If Not arv.ReportSource Is Nothing Then
arv.ReportSource.Cancel
Set arv.ReportSource = Nothing
End If
'Load the saved RPX file into a report object
rpt.LoadLayout App.Path & "\sample report.rpx"
'Load the report object into the designer
ard.LoadFromObject rpt
Exit Sub
errHndl:
MsgBox "Error in Design Preview: " & Err.Number & " " & Err.Description
End Sub
Save these changes.
Loading DSR (ActiveX Designer) Files
The run-time designer can also load ActiveReport's ActiveX Designers included within the project. To demonstrate this capability:
Name rptSample
Private Sub Form_Load()
'Set active Tab to the designer
SSTab1.Tab = 0
Set rpt = New ActiveReport
'Activate all the toolbars
ard.ToolbarsVisible = ddTBToolBox + ddTBAlignment + ddTBExplorer + _
ddTBFields + ddTBFormat + ddTBMenu + ddTBPropertyToolbox + ddTBStandard
ard.ToolbarsAccessible = ddTBToolBox + ddTBAlignment + ddTBExplorer + _
ddTBFields + ddTBFormat + ddTBMenu + ddTBPropertyToolbox + ddTBStandard
'Load the ActiveX designer into the run-time designer
ard.LoadFromObject rptSample
End Sub
Do not save these changes.