Saving And Loading RDF Files

ActiveReports allows reports to be saved into their own standard format called an RDF file (Report Document Format). Once a report has been saved to an RDF file, it can be loaded into the viewer control and used to display reports in custom preview applications and on the web. Below is a sample project demonstrating how to save and load these RDF files.

  1. Create a new Visual Basic EXE project.
  2. Change the name of From1 to frmRDFs.
  3. Create a new ActiveReport, as shown in the first tutorial, and set the report's name to rptRDFs (See Chapter 15).

With frmRDFs

  1. Add the Data Dynamics ActiveReports Viewer 2.0 control to frmRDFs.
  2. Add two command buttons below the viewer control and set their properties as follows:
    Name cmdSave cmdLoad
    Caption Save Report Load Report
    Enabled True False
  3. Add the following code to the cmdSave_Click event:

    Private Sub cmdSave_Click()
    rptRDFs.Run
    rptRDFs.Pages.Save App.Path & "\SavedRDF.RDF"
    cmdLoad.Enabled = True
    End Sub

  4. Add the following code to the cmdLoad_Click event:

    Private Sub cmdLoad_Click()
    ARViewer21.Pages.Load App.Path & "\SavedRDF.RDF"
    frmRDFs.Caption = "RDF File loaded: " & App.Path & "\SavedRDF.RDF"
    End Sub

With rptRDFs

  1. Insert a ADO data control in the Detail section.
  2. Connect to Nwind.mdb (see Chapter 3 for help with connecting).
  3. Set the data control's source property to the following SQL statement:

    SELECT * FROM Employees ORDER BY Title

  4. Remove the PageHeader/Footer sections from the report.
  5. Add a GroupHeader/Footer to the report.
  6. Set the GroupHeader's properties as follows:
    BackColor Black
    BackStyle 1-Normal
    CanShrink False
    Height 330
    DataField EmployeeID
    GrpKeepTogether 2-All
    KeepTogether True
  7. Place three fields in the GroupHeader and set their properties as follows:
    Name txtEmployeeID txtFirstName txtLastName
    Text EmployeeID FirstName LastName
    DataField EmployeeID FirstName LastName
    Height 270 270 270
    Left 0 1440 2880
    Top 0 0 0
    Width 1260 1440 1440
  8. Set the GroupFooter's properties as follows:
    BackColor Black
    BackStyle 1-Normal
    CanGrow False
    Height 100
    KeepTogether True
  9. Select the Detail section and set the section's properties as follows:
    BackColor &H00404040&
    BackStyle Normal
    CanShrink False
    Height 1650
  10. Place a Shape control in the Detail Section and set its properties as follows:
    BackColor &H00C0C0C0&
    BackStyle 1-ddBKNormal
    Height 720
    Left 0
    Top 450
    Width 9360
  11. Right-click on the Shape control and select "Send To Back."
  12. Place eight textboxes in the Detail section and set their properties as follows:
    Name txtTitle txtHireDate txtExtension txtHomePhone txtAddress txtCity txtCountry txtPostalCode
    Text Title HireDate Extension HomePhone Address City Country Postal Code
    DataField Title HireDate Extension HomePhone Address City Country Postal Code
    Height 270 270 270 270 270 270 270 270
    Left 90 1620 3150 90 90 90 1620 3060
    Top 90 90 90 1260 540 810 810 810
    Width 1440 1440 1440 1440 9180 1530 1440 6210
    ForeColor &H00E0E0E0& &H00E0E0E0& &H00E0E0E0& &H00E0E0E0&        
    BackColor         &H00E0E0E0& &H00E0E0E0& &H00E0E0E0& &H00E0E0E0&
    BackStyle         1-ddBKNormal 1-ddBKNormal 1-ddBKNormal 1-ddBKNormal
  13. Save the project and run it.