ComponentOne FlexReport for WinForms
Importing Microsoft Access Reports
Working with FlexReportDesigner > Importing Reports in FlexReportDesigner > Importing Microsoft Access Reports

To import a Microsoft Access file, select a Microsoft Access file (MDB or ADP) and the Designer scans the file and shows a dialog box where you can select which reports you would like to import:

The dialog box also allows you to specify if the Designer should clear all currently defined reports before starting the import process.

Note that importing Microsoft Access report requires Access to be installed on the computer. Once the report is imported into the Designer, Access is no longer required.

The import process handles most elements of the source reports, with a few exceptions:

These limitations affect a relatively small number of reports, but you should preview all reports after importing them, to make sure they still work correctly.

Importing the C1NWind.mdb File

To illustrate how the Designer fares in a real-life example, try importing the C1NWind.mdb file. It contains the following 13 reports. (The NWind.xml file that ships with C1FlexReport already contains all the following modifications.)

  1. Alphabetical List of Products

    No action required.

  2. Catalog

    No action required.

  3. Customer Labels

    No action required.

  4. Employee Sales by Country

    This report contains code which needs to be translated manually. The following code should be assigned to the Group 1 Header OnPrint property:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    If SalespersonTotal > 5000 Then            
      ExceededGoalLabel.Visible = True            
      SalespersonLine.Visible = True            
    Else            
      ExceededGoalLabel.Visible = False            
      SalespersonLine.Visible = False            
    End If
    

    To write code in C#

    C#
    Copy Code
    if (SalespersonTotal > 5000)                 
    {                
      ExceededGoalLabel.Visible = true;                
      SalespersonLine.Visible = true;                
    } else
    
    {                
      ExceededGoalLabel.Visible = false;                
      SalespersonLine.Visible = false;               
    }
    

  5. Invoice

    No action required.

  6. Products by Category

    No action required.

  7. Sales by Category

    This report contains a Chart control that is not imported. To add a chart to your report, you can use the Chart field.

  8. Sales by Category Subreport

    No action required.

  9. Sales by Year

    This report contains code and references to a Form object which need to be translated manually. To replace the Form object in the Data panel, add a "ShowDetails" parameter. Set its DataType property to Boolean and Value property to False:

    Use the new parameter in the report's OnOpen event:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim script As String = _                            
      "bDetails = [Show Details]" & vbCrLf & _                            
      "Detail.Visible = bDetails" & vbCrLf & _                            
      "[Group 0 Footer].Visible = bDetails" & vbCrLf & _                            
      "DetailsLabel.Visible = bDetails" & vbCrLf & _                            
      "LineNumberLabel2.Visible = bDetails" & vbCrLf & _                            
      "Line15.Visible = bDetails" & vbCrLf & _                           
      "SalesLabel2.Visible = bDetails" & vbCrLf & _                            
      "OrdersShippedLabel2.Visible = bDetails" & vbCrLf & _                            
      "ShippedDateLabel2.Visible = bDetails" & vbCrLf & _                            
      "Line10.Visible = bDetails"                        
    C1FlexReport1.Sections.Detail.OnPrint = script
    

    To write code in C#

    C#
    Copy Code
    string script = "bDetails = [Show Details]" +                                  
      "Detail.Visible = bDetails\r\n" +                                  
      "[Group 0 Footer].Visible = bDetails\r\n" +                                  
      "DetailsLabel.Visible = bDetails\r\n" +                                  
      "LineNumberLabel2.Visible = bDetails\r\n" +                                  
      "Line15.Visible = bDetails\r\n" +                                  
      "SalesLabel2.Visible = bDetails\r\n" +                                  
      "OrdersShippedLabel2.Visible = bDetails\r\n" +                                 
      "ShippedDateLabel2.Visible = bDetails\r\n" +                                 
      "Line10.Visible = bDetails";                                
    c1FlexReport1.Sections.Detail.OnPrint = script;
    

    Finally, two more lines of code need to be translated:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Sections ("Detail").OnPrint = _                                    
      "PageHeader.Visible = True"                                    
    Sections("Group 0 Footer).OnPrint = _                                    
      "PageHeader.Visible = False"
    

    To write code in C#

    C#
    Copy Code
    Sections ("Detail").OnPrint =                                          
      "PageHeader.Visible = true";                                        
    Sections("Group 0 Footer).OnPrint =                                         
      "PageHeader.Visible = false";
    

  10. Sales by Year Subreport

    No action required.

  11. Sales Totals by Amount

    This report contains code that needs to be translated manually. The following code should be assigned to the Page Header OnPrint property:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    PageTotal = 0
    

    To write code in C#

    C#
    Copy Code
    PageTotal = 0;
    

    The following code should be assigned to the Detail OnPrint property:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    PageTotal = PageTotal + SaleAmount                                                    
    HiddenPageBreak.Visible = (Counter = 10)
    

    To write code in C#

    C#
    Copy Code
    PageTotal = PageTotal + SaleAmount;                                                        
    HiddenPageBreak.Visible = (Counter = 10);
    

  12. Summary of Sales by Quarter

    No action required.

  13. Summary of Sales by Year

    No action required.

Summing up the information on the table, out of the 13 reports imported from the NorthWind database: nine did not require any editing, three required some code translation, and one had a chart control that required adding a Chart field.