Underline a portion of Text via VBA

  • Thread starter Thread starter Irshad Alam
  • Start date Start date
I

Irshad Alam

In my report I have a textbox named: Text110
Controlsource ="Svc " & [Svc/Qtn] & " No.: " & [QtnNo] & [QtnAB]

The result in the preview is like below :

Svc Revised-Estimation No.2010/2356


My requirement is to under line only the portion 2010/2356 only via VBA code.

I may have put the line manually under the text, but the description inside
the text keep changing some time Estimate, some time Revised-Estimate,
therefore the allingment of the line underneath changes. That is the reason
for a code, which will draw a line exactly calculating like from
Right(Text110,9)

Please advice a code to do this and at what event.

Thanking in advance

Regards

Irshad
 
In my report I have a textbox named:  Text110
Controlsource ="Svc " & [Svc/Qtn] & " No.: " & [QtnNo] & [QtnAB]

The result in the preview is like below :

Svc Revised-Estimation No.2010/2356

My requirement is to under line only the portion 2010/2356 only via VBA code.

I may have put the line manually under the text, but the description inside
the text keep changing some time Estimate, some time Revised-Estimate,
therefore the allingment of the line underneath changes. That is the reason
for a code, which will draw a line exactly calculating like from
Right(Text110,9)

Please advice a code to do this and at what event.

Thanking in advance

Regards

Irshad

Hi Irshad,

It is my belief that you cannot underline part of a text box, so if
you create a label for "Svc " and then an underlined text box control
for [Svc/Qtn] and another text box (ununderlined) for " No.: " &
[QtnNo] & [QtnAB]. I know that this is messy and I apologise for that
but it easily acheives the desired result.

Nick
 
Hi Sir,

Making label and getting them together and again the text length (sometime
less and some time more) which keeps the space inbetween.

Sorry, to say, not satisfied by the solution.

Please re-check and advice any other possible to handle my required
situation, something with draw line etc. codes.

Regards

Irshad





Nick 'The Database Guy' said:
In my report I have a textbox named: Text110
Controlsource ="Svc " & [Svc/Qtn] & " No.: " & [QtnNo] & [QtnAB]

The result in the preview is like below :

Svc Revised-Estimation No.2010/2356

My requirement is to under line only the portion 2010/2356 only via VBA code.

I may have put the line manually under the text, but the description inside
the text keep changing some time Estimate, some time Revised-Estimate,
therefore the allingment of the line underneath changes. That is the reason
for a code, which will draw a line exactly calculating like from
Right(Text110,9)

Please advice a code to do this and at what event.

Thanking in advance

Regards

Irshad

Hi Irshad,

It is my belief that you cannot underline part of a text box, so if
you create a label for "Svc " and then an underlined text box control
for [Svc/Qtn] and another text box (ununderlined) for " No.: " &
[QtnNo] & [QtnAB]. I know that this is messy and I apologise for that
but it easily acheives the desired result.

Nick
.
 
Check out the following for some ideas especially if you are using a version
prior to Access 2007.
http://www.lebans.com/mixbold-plain.htm
http://www.lebans.com/textwidth-height.htm
http://www.lebans.com/richtext.htm

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Irshad said:
Hi Sir,

Making label and getting them together and again the text length (sometime
less and some time more) which keeps the space inbetween.

Sorry, to say, not satisfied by the solution.

Please re-check and advice any other possible to handle my required
situation, something with draw line etc. codes.

Regards

Irshad





Nick 'The Database Guy' said:
In my report I have a textbox named: Text110
Controlsource ="Svc " & [Svc/Qtn] & " No.: " & [QtnNo] & [QtnAB]

The result in the preview is like below :

Svc Revised-Estimation No.2010/2356

My requirement is to under line only the portion 2010/2356 only via VBA code.

I may have put the line manually under the text, but the description inside
the text keep changing some time Estimate, some time Revised-Estimate,
therefore the allingment of the line underneath changes. That is the reason
for a code, which will draw a line exactly calculating like from
Right(Text110,9)

Please advice a code to do this and at what event.

Thanking in advance

Regards

Irshad
Hi Irshad,

It is my belief that you cannot underline part of a text box, so if
you create a label for "Svc " and then an underlined text box control
for [Svc/Qtn] and another text box (ununderlined) for " No.: " &
[QtnNo] & [QtnAB]. I know that this is messy and I apologise for that
but it easily acheives the desired result.

Nick
.
 
You can use the Print method in your report. I just tested this with the
employee table in Northwind. I wanted to create a text box with FirstName
Lastname "Title: " & Title with only the title underlined. Make sure you have
each of the values bound to text boxes in your report. They can all be hidden.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim lngLeft As Long
lngLeft = Me.text110.Left
Me.text110.Visible = False
Me.CurrentY = Me.text110.Top
Me.CurrentX = Me.text110.Left
Me.FontName = Me.text110.FontName
Me.FontSize = Me.text110.FontSize
Me.ForeColor = vbBlack 'maybe change if necessary
Me.FontUnderline = False
Me.Print Me.FirstName & " " & Me.LastName & " Title: "
Me.FontUnderline = True
'set the Y value back up otherwise the next print will be lower
Me.CurrentY = Me.text110.Top
Me.Print Me.Title
End Sub
 
Thank you so much. After changing little, it worked pefect. The changed I did
as below :

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim lngLeft As Long
lngLeft = Me.Text110.left
Me.Text110.Visible = False
Me.CurrentY = Me.Text110.Top
Me.CurrentX = Me.Text110.left
Me.FontName = Me.Text110.FontName
Me.fontsize = Me.Text110.fontsize
Me.ForeColor = vbBlack 'maybe change if necessary
Me.FontUnderline = False
Me.Print Me.[Svc/Qtn] & " No.:"
Me.FontUnderline = True
'set the Y value back up otherwise the next print will be lower
Me.CurrentY = Me.Text110.Top
Me.Print " " & Me.[QtnNo] & Me.[QtnAB]
End Sub



Best regards

Irshad
UAE



Duane Hookom said:
You can use the Print method in your report. I just tested this with the
employee table in Northwind. I wanted to create a text box with FirstName
Lastname "Title: " & Title with only the title underlined. Make sure you have
each of the values bound to text boxes in your report. They can all be hidden.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim lngLeft As Long
lngLeft = Me.text110.Left
Me.text110.Visible = False
Me.CurrentY = Me.text110.Top
Me.CurrentX = Me.text110.Left
Me.FontName = Me.text110.FontName
Me.FontSize = Me.text110.FontSize
Me.ForeColor = vbBlack 'maybe change if necessary
Me.FontUnderline = False
Me.Print Me.FirstName & " " & Me.LastName & " Title: "
Me.FontUnderline = True
'set the Y value back up otherwise the next print will be lower
Me.CurrentY = Me.text110.Top
Me.Print Me.Title
End Sub
--
Duane Hookom
Microsoft Access MVP


Irshad Alam said:
In my report I have a textbox named: Text110
Controlsource ="Svc " & [Svc/Qtn] & " No.: " & [QtnNo] & [QtnAB]

The result in the preview is like below :

Svc Revised-Estimation No.2010/2356


My requirement is to under line only the portion 2010/2356 only via VBA code.

I may have put the line manually under the text, but the description inside
the text keep changing some time Estimate, some time Revised-Estimate,
therefore the allingment of the line underneath changes. That is the reason
for a code, which will draw a line exactly calculating like from
Right(Text110,9)

Please advice a code to do this and at what event.

Thanking in advance

Regards

Irshad
 
Back
Top