Microsoft KB Archive/128389

= ACC2: Cannot Export Run Time Font Style Changes to RTF =

Article ID: 128389

Article Last Modified on 11/6/2000

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q128389



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:

 Open the sample database NWIND.MDB. Make a copy of the Employee Sales Subreport report, and name it RTF_FIX. Open the RTF_FIX report in Design view. 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. Delete the label associated with the Field6 control.  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. </li>  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 </li> From the File menu, choose Print Preview. Note that sales that are greater than $50,000 are underlined.</li> From the File menu, choose the Output To command.</li> In the Select Format list box, select Rich Text Format (*.rtf), and then choose the OK button.</li> In the File Name box, type the filename TESTFIX.RTF, and then choose OK.</li> 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.</li></ol>

<div class="moreinformation_section">

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
<ol> Open the sample database NWIND.MDB.</li> Make a copy of the Employee Sales Subreport, and name it RTF_Test.</li> Open the RTF_Test report in Design view.</li>  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 </li> From the File menu, choose Print Preview. Note that sales greater than $50,000 are underlined.</li> From the File menu, choose the Output To command.</li> In the Select Format list box, select Rich Text Format (*.rtf), and then choose the OK button.</li> In the File Name box, type TEST.RTF, and then choose OK.</li> 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.</li></ol>

<div class="references_section">