ACC2: Cannot Export Run Time Font Style Changes to RTF

ID: Q128389


The information in this article applies to:


SYMPTOMS

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 Output To command to save the report as a Rich Text Format (RTF) 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 NWIND.MDB.


  2. Make a copy of the Employee Sales Subreport report, and name it RTF_FIX.


  3. Open the RTF_FIX report in Design view.


  4. If the field list is not displayed, choose Field List from the View menu. Drag the Employee Sales field from the field list so that it is on top of the existing Employee Sales control in the detail section. This new control has the name Field6 by default.


  5. Delete the label associated with the Field6 control.


  6. Set the following properties for the Field6 field:
    
           Format: Currency
           BorderStyle: Clear
           FontUnderline: Yes 

    NOTE: This example sets only the FontUnderline property. To set the FontItalics or FontWeight properties, repeat the steps above for those properties.


  7. Set the detail section's OnFormat property to the following event procedure:
    
           Sub Detail1_Format (Cancel As Integer, FormatCount As Integer)
              If [Employee Sales] > 50000 Then
                 Me![Field6].visible = -1
                 Me![Employee Sales].visible = 0
              Else
                 Me![Field6].visible = 0
                 Me![Employee Sales].visible = -1
              End If
           End Sub 


  8. From the File menu, choose Print Preview. Note that sales that are greater than $50,000 are underlined.


  9. From the File menu, choose the Output To command.


  10. In the Select Format list box, select Rich Text Format (*.rtf), and then choose the OK button.


  11. In the File Name box, type the filename TESTFIX.RTF, and then choose OK.


  12. Open the TESTFIX.RTF file in a word processor (such as Microsoft Word for Windows) that supports the RTF format. Note that sales amounts exceeding $50,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 NWIND.MDB.


  2. Make a copy of the Employee Sales Subreport, 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:
    
          Sub Detail1_Format (Cancel As Integer, FormatCount As Integer)
             If [Employee Sales] > 50000 Then
               Me![Employee Sales].fontunderline = True
             Else [Employee Sales].fontunderline = False
             End If
          End Sub 


  5. From the File menu, choose Print Preview. Note that sales greater than $50,000 are underlined.


  6. From the File menu, choose the Output To command.


  7. In the Select Format list box, select Rich Text Format (*.rtf), and then choose the OK button.


  8. In the File Name box, type TEST.RTF, and then choose OK.


  9. Open TEST.RTF in a word processor (such as Microsoft Word for Windows) that supports the RTF format. Note that sales exceeding $50,000 are not underlined.



REFERENCES

For more information about the Output To command, search for "Output To" then "Output To Command (File Menu)" using the Microsoft Access Help menu.


Keywords          : kbusage OtpRtf 
Version           : 2.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: April 9, 1999