Fomatting a text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Is there a way to show some part of the text as highlighted or bold in a
text box thru VBA code?

Thanks for your help
Krishna
 
You might need to use a Rich Text control. If you are attempting to do this
in a report then you can use the Print method of the report in the On Format
event. For instance if you were reporting the Customer table from Northwind
and wanted to concatenate the CustomerID and CompanyName with the first part
bolded you could use the following code in the On Format event of the
section containing the text. NOTE: the CustomerID and CompanyName would need
to be bound to controls in that report section. The controls could/should be
invisilbe.

My code also assume you add an invisible line named "LineTop" where you want
the text to appear.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Dim intSpacing As Integer
intSpacing = 60 'space between fields
Me.CurrentX = Me.LineTop.Left
Me.CurrentY = Me.LineTop.Top
Me.FontSize = 10
Me.FontBold = True
Me.Print Me.CustomerID 'must be bound control
Me.FontBold = False
Me.CurrentY = Me.LineTop.Top
Me.CurrentX = Me.CurrentX + intSpacing
Me.Print Me.CompanyName 'must be bound control
End Sub
 
Back
Top