ACC95: Cannot Export Run-Time Font Style Changes to RTF

Last reviewed: August 28, 1997
Article ID: Q141105
The information in this article applies to:
  • Microsoft Access version 7.0

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

When you conditionally set the font styles for a report's controls using a section's OnFormat property, the changes are lost when you choose the Save As/Export command to save the report as a Rich Text Format (RFT) file. For example, if you change a control's FontUnderline, FontItalics, or FontWeight property at run time, the change does not appear when you output the report to an RTF file.

RESOLUTION

To work around this behavior, you can use the following steps to stack two bound controls (one with font styles and one without font styles) on each other and set the Visible property to specify which control is displayed at run time:

  1. Open the sample database Northwind.mdb, and make a copy of the Employee Sales By Country report. Name it Rtf_Fix.

  2. Open the Rtf_Fix report in Design view. If the field list is not displayed, click Field List on the View menu. Drag the SaleAmount field from the field list so that it is on top of the existing SaleAmount control in the detail section. Change the Name property of the control to Rtf_Sale.

  3. Delete the label associated with the Rtf_Sale control, and then set the following properties for the Rtf_Sale control:

          Format: Currency
          BorderStyle: Transparent
          FontUnderline: Yes
    

    NOTE: This example sets only the FontUnderline property. To set the FontItalics or FontWeight property, you would need to set those properties also.

  4. Set the detail section's OnFormat property to the following event procedure:

          Private Sub Detail_Format (Cancel as Integer, FormatCount as _
    
                 Integer)
           If Me!SalespersonTotal > 5000 Then
              Me!RTF_Sale.visible = True
              Me!SaleAmount.visible = False
           Else
              Me!RTF_Sale.visible = False
              Me!SaleAmount.visible = True
           End If
          End Sub
    
    

  5. On the File menu, click Print Preview. When you are prompted for a beginning and ending date, enter 01/01/95 and 01/20/95, respectively. Note that the sales amounts for which the total sales is greater than $5,000 are underlined.

  6. On the File menu, click Save As/Export.

  7. In the Save As dialog box, click to select "To an external File or Database," and then click OK.

  8. In the Save Table dialog box, under Save As Type, select Rich Text Format (*.rtf), and then click Export.

  9. Open the Rtf_Fix.Rtf file in a word processor (such as Microsoft Word for Windows) that supports the RTF format. Note that the sales amounts for which the total sales is greater than $5,000 are underlined.

MORE INFORMATION

When Microsoft Access outputs data to an RTF file, it uses the first data record to determine the format for that section. If a control in the first record is underlined, that control is underlined for all subsequent records in the RTF file. Microsoft Access ignores any format changes after the first record.

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb.

  2. Make a copy of the Employee Sales By Country report and name it Rtf_Test.

  3. Open the Rtf_Test report in Design view.

  4. Set the detail section's OnFormat property to the following event procedure:

          Private Sub Detail_Format (Cancel as Integer, FormatCount as Integer)
          If Me!SalespersonTotal >5000 Then
    
            Me!SaleAmount.FontUnderline = True
          Else
            Me!SaleAmount.FontUnderline = False
          End If
          End Sub
    
    

  5. On the File menu, click Print Preview. When you are prompted for a beginning and ending date, enter 01/01/95 and 01/20/95, respectively. Note that sales amounts for which the sales total is greater than $5,000 are underlined.

  6. On the File menu, click Save As/Export.

  7. In the Save As dialog box, click to select "To an external File or Database," and then click OK.

  8. In the Save Table dialog box, under Save As Type, select Rich Text Format (*.rtf), and then click Export.

  9. Open Rtf_Test.RTF in a word processor (such as Microsoft Word for Windows) that supports the RTF format. Note that the sales amounts are not underlined.

REFERENCES

For more information about the Save As/Export option, search on the phrase "exporting data to another file format" using the Microsoft Access 7.0 Help Index.

Keywords          : IntpOthr kbinterop PgmHowTo
Version           : 7.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbprb
Solution Type     : kbworkaround


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.