The information in this article applies to:
- Microsoft Access version 2.0
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.
- 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
- From the File menu, choose Print Preview. Note that sales that are
greater than $50,000 are underlined.
- From the File menu, choose the Output To command.
- In the Select Format list box, select Rich Text Format (*.rtf), and
then choose the OK button.
- In the File Name box, type the filename "TESTFIX.RTF" (without the
quotation marks), and then choose OK.
- 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
- Open the sample database NWIND.MDB.
- Make a copy of the Employee Sales Subreport, and name it RTF_Test.
- Open the RTF_Test report in Design view.
- 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
- From the File menu, choose Print Preview. Note that sales greater
than $50,000 are underlined.
- From the File menu, choose the Output To command.
- In the Select Format list box, select Rich Text Format (*.rtf), and then
choose the OK button.
- In the File Name box, type "TEST.RTF" (without quotation marks),
and then choose OK.
- 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.
|