Formatting Text "Within" a Control

D

Debra Farnham

Win 2K, Access 2K

Using the following code (which I believe I found in a post by Stephan
Lebans), I was able to simulate formatting parts of text within a control.
However, I cannot seem to get it to wrap on the report and it gets truncated
at the margin.

Any help getting this text to wrap would be greatly appreciated.

TIA

Debra

*********************************************************

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

Dim strFirst As String 'Unformatted text in string
Dim strEnd As String 'Remaining unformatted text
Dim strText As String 'Formatted text in string
Dim intPosition As Integer
Dim intPosition2 As Integer
Dim CtlDetail As Control
Dim strLast As String


For Each CtlDetail In Me.Section(acDetail).Controls
If CtlDetail.Name = "txtAward" Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, "to")
strFirst = Left(.Value, intPosition + 2)
strLast = Mid(.Value, intPosition + 2)
intPosition2 = InStr(1, strLast, "on")
strText = Mid(strLast, 1, intPosition2 - 1)
strEnd = Mid(strLast, intPosition2)
End With


With Me

' Grab Controls current Font settings
.FontName = CtlDetail.FontName
.fontsize = CtlDetail.fontsize


.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
Me.Print strFirst;

'font effects for formatted section
.ForeColor = "16711680" 'Blue
.FontItalic = True
.FontBold = True

Me.Print strText;

' Reset Font-> NO Bold, italics or color for end of text
.ForeColor = "0" 'Black
.FontItalic = False
.FontBold = False

Me.Print strEnd

End With

End If
Next

End Sub
 
S

Stephen Lebans

That code is clearly intendended to be a SINGLE line solution only.
If I remember correctly one or possible both of the other two example
MDB's show how to use the code to produce 2 or 3 line sof output. If you
require more than two lines of formatted output you really should
consider using a Rich Text ActiveX control.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
D

Debra Farnham

Thank you for your response Stephen.

I will work with the Rich Text ActiveX control.

Debra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top