Microsoft KB Archive/141105

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

Article ID: 141105

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 95 Standard Edition

-



This article was previously published under Q141105



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



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 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:  Open the sample database Northwind.mdb, and make a copy of the Employee Sales By Country report. Name it Rtf_Fix. 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. 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.  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  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. On the File menu, click Save As/Export.</li> In the Save As dialog box, click to select "To an external File or Database," and then click OK.</li> In the Save Table dialog box, under Save As Type, select Rich Text Format (*.rtf), and then click Export.</li> 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.</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 Northwind.mdb.</li> Make a copy of the Employee Sales By Country report 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: 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 </li> 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.</li> On the File menu, click Save As/Export.</li> In the Save As dialog box, click to select "To an external File or Database," and then click OK.</li> In the Save Table dialog box, under Save As Type, select Rich Text Format (*.rtf), and then click Export.</li> 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.</li></ol>

<div class="references_section">