Microsoft KB Archive/310802

= ACC2000: How to Format Words on a Control in a Report =

Article ID: 310802

Article Last Modified on 1/16/2007

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q310802



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
This article shows how to format words on a control in a report. The article uses an example from the Northwind database, a text box composed of concatenated first and last name fields from the Employees table.



MORE INFORMATION
The following example demonstrates the procedure for making the firstname field in the text box bold while keeping the lastname field normal in a report.  Copy Microsoft Rich TextBox ActiveX Control (the Richtx32.ocx file) to the C:\Windows\System folder. Make sure that you copy version 6.0.88.4 or later of the Richtx32.ocx file.

Version 6.0.88.4 or later of the Richtx32.ocx file comes with Microsoft Visual Studio 6.0 Service Pack 4 (SP4) or later. If you do not have the appropriate version, you can download Visual Studio 6.0 SP5 from the following Web site, and then run the update to obtain the correct version of the file:

http://msdn2.microsoft.com/en-us/vstudio/aa718363.aspx

Note that to be able to run the update, you must have at least one of the Visual Studio programs installed on your computer. Also, there is a problem with the Rich TextBox Control. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

212733 FIX: Contents of Rich TextBox Control Not Viewable in Report

 Register the Rich TextBox Control by using the Regsvr32.exe program:  Click Start, and then click Run. In the Open box, type the following command, and then press ENTER:

Regsvr32 C:\Windows\System\Richtx32.ocx

  Create a concatenated field in a query that contains first and last names from the Employees table:  In the Database window in Access 2000, click Queries under Objects, and then click New.</li> In the New Query dialog box, click Design View, and then click OK.</li> In the Show Table dialog box, click the Employees table on the Tables tab, click Add, and then click Close.</li> In the Field box in the query design grid, type the following:

concatenate: [firstname] & &quot; &quot; & [lastname]

</li> On the File menu, click Save, type a name for the query, and then click OK.</li></ol> </li> Create a report that is based on the query and that uses the Rich TextBox ActiveX Control:  In the Database window, click Reports under Objects, and then click New.</li> In the New Report dialog box, click Design View, click the newly created query in the Choose the table or query where the object's data comes from box, and then click OK.</li> On the Insert menu, click ActiveX Control.</li> In the Select ActiveX Control dialog box, click Microsoft Rich TextBox Control 6.0 (SP4), and then click OK.</li> Right-click the inserted Rich TextBox control, and then click Properties.</li> On the Data tab, make sure that concatenate is listed in the Control Source box.</li></ol> </li> Right-click the Detail section on the report, and then click Build Event.</li> In the Choose Builder dialog box, click Code Builder, and then click OK.</li> <li> Under the Detail_Format event, type the following code: Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Dim theFirstName As String Dim theLastName As String

theFirstName = Left(Me.concatenate.Value, InStr(1, Me.concatenate.Value, &quot; &quot;)) theLastName = Mid(Me.concatenate.Value, InStr(1, Me.concatenate.Value, &quot; &quot;) +1)

With ActiveXCtl15 'You need to replace ActiveXCt115 with the name of the Rich TextBox 'control that you inserted.

.SelBold = True .SelText = theFirstName .SelBold = False .SelText = theLastName

End With

End Sub </li> <li>Preview the report.</li></ol>

Note that Print Preview may be blank on the ActiveX control. However, you can print the report to view the results. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

212733 FIX: Contents of Rich TextBox Control Not Viewable in Report

Additional query words: pra

Keywords: kbhowto KB310802

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.