"Bold" text field on a report

J

JimP

I have a text field on a report that is the concatenation of a label and a
field name. How can I bold the label portion? e.g.

Text111 = "LabelName: " & [FieldName]

LabelName portion should print in bold
 
G

Guest

In design mode, select the label and open the properties dialog. select the
format property and look for the Font Weight property. Select what you want
from the dropdown.
 
D

Douglas J. Steele

Um, that would make everything in the text box bold, Dave, not just
"LabelName: "

Stephen Lebans has some examples of how to mix Bold and Plain at
http://www.lebans.com/mixbold-plain.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Klatuu said:
In design mode, select the label and open the properties dialog. select
the
format property and look for the Font Weight property. Select what you
want
from the dropdown.
--
Dave Hargis, Microsoft Access MVP


JimP said:
I have a text field on a report that is the concatenation of a label and
a
field name. How can I bold the label portion? e.g.

Text111 = "LabelName: " & [FieldName]

LabelName portion should print in bold
 
J

JimP

Thanks for the pointer. The following code, while simple, is working -
except that I want to right align the text (Text186). I'm not sure that is
possible. The value for Me.CurrentX seems to force a left align.

Private Sub PageHeader0_Print(Cancel As Integer, PrintCount As Integer)
Me!Text186.Visible = False
With Me
.ScaleMode = TWIPS
.FontBold = True
.CurrentX = Me!Text186.Left
.CurrentY = Me!Text186.Top
Me.Print "Client Ref : ";
.FontBold = False
Me.Print Me!Text186
End With

End Sub


Douglas J. Steele said:
Um, that would make everything in the text box bold, Dave, not just
"LabelName: "

Stephen Lebans has some examples of how to mix Bold and Plain at
http://www.lebans.com/mixbold-plain.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Klatuu said:
In design mode, select the label and open the properties dialog. select
the
format property and look for the Font Weight property. Select what you
want
from the dropdown.
--
Dave Hargis, Microsoft Access MVP


JimP said:
I have a text field on a report that is the concatenation of a label and
a
field name. How can I bold the label portion? e.g.

Text111 = "LabelName: " & [FieldName]

LabelName portion should print in bold
 
D

Douglas J. Steele

Is there some reason you can't use two text boxes?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JimP said:
Thanks for the pointer. The following code, while simple, is working -
except that I want to right align the text (Text186). I'm not sure that is
possible. The value for Me.CurrentX seems to force a left align.

Private Sub PageHeader0_Print(Cancel As Integer, PrintCount As Integer)
Me!Text186.Visible = False
With Me
.ScaleMode = TWIPS
.FontBold = True
.CurrentX = Me!Text186.Left
.CurrentY = Me!Text186.Top
Me.Print "Client Ref : ";
.FontBold = False
Me.Print Me!Text186
End With

End Sub


Douglas J. Steele said:
Um, that would make everything in the text box bold, Dave, not just
"LabelName: "

Stephen Lebans has some examples of how to mix Bold and Plain at
http://www.lebans.com/mixbold-plain.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Klatuu said:
In design mode, select the label and open the properties dialog. select
the
format property and look for the Font Weight property. Select what you
want
from the dropdown.
--
Dave Hargis, Microsoft Access MVP


:

I have a text field on a report that is the concatenation of a label
and a
field name. How can I bold the label portion? e.g.

Text111 = "LabelName: " & [FieldName]

LabelName portion should print in bold
 
J

JimP

No - cosmetically this solution seems to right align better because the
field length varies considerably. The code below is working though.

One question - is it necessary to loop through the controls collection to
identify the control, rather than addressing it directly (i.e. For Each
CtlDetail In Me.Section(acPageHeader).Controls)

=========================
'Subroutine to concatenate a label (bold) and a text field (unbold) and
right align
Private Sub PageHeader0_Print(Cancel As Integer, PrintCount As Integer)
Dim CtlDetail As control

strLabel = "Client Ref : " 'Label Description
strField = "Text186" 'Field Name

For Each CtlDetail In Me.Section(acPageHeader).Controls
If CtlDetail.NAME = strField Then
CtlDetail.Visible = False
Me.ScaleMode = TWIPS
intFieldWidth = CtlDetail.Width
Me.FontName = CtlDetail.FontName
Me.FontSize = CtlDetail.FontSize
intTextWidth = TextWidth(CtlDetail)
Me.FontBold = True
intLabelWidth = TextWidth(strLabel)
Me.CurrentX = CtlDetail.Left + intFieldWidth - intLabelWidth -
intTextWidth
Me.CurrentY = CtlDetail.Top + 30 'set to center TNR 11 pt
vertically
Me.Print strLabel;
Me.FontBold = False
Me.Print CtlDetail.Value
End If
Next CtlDetail

End Sub


Douglas J. Steele said:
Is there some reason you can't use two text boxes?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JimP said:
Thanks for the pointer. The following code, while simple, is working -
except that I want to right align the text (Text186). I'm not sure that
is possible. The value for Me.CurrentX seems to force a left align.

Private Sub PageHeader0_Print(Cancel As Integer, PrintCount As Integer)
Me!Text186.Visible = False
With Me
.ScaleMode = TWIPS
.FontBold = True
.CurrentX = Me!Text186.Left
.CurrentY = Me!Text186.Top
Me.Print "Client Ref : ";
.FontBold = False
Me.Print Me!Text186
End With

End Sub


Douglas J. Steele said:
Um, that would make everything in the text box bold, Dave, not just
"LabelName: "

Stephen Lebans has some examples of how to mix Bold and Plain at
http://www.lebans.com/mixbold-plain.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


In design mode, select the label and open the properties dialog.
select the
format property and look for the Font Weight property. Select what you
want
from the dropdown.
--
Dave Hargis, Microsoft Access MVP


:

I have a text field on a report that is the concatenation of a label
and a
field name. How can I bold the label portion? e.g.

Text111 = "LabelName: " & [FieldName]

LabelName portion should print in bold
 
D

Douglas J. Steele

I'm not aware of a reason to loop.

With Me.Controls(strField)
.Visible = False
Me.ScaleMode = TWIPS
intFieldWidth = .Width
Me.FontName = .FontName
Me.FontSize = .FontSize
intTextWidth = TextWidth(Me.Controls(strField))
Me.FontBold = True
intLabelWidth = TextWidth(strLabel)
Me.CurrentX = .Left + intFieldWidth - intLabelWidth - intTextWidth
Me.CurrentY = .Top + 30 'set to center TNR 11 pt vertically
Me.Print strLabel;
Me.FontBold = False
Me.Print .Value
End With

should be sufficient.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JimP said:
No - cosmetically this solution seems to right align better because the
field length varies considerably. The code below is working though.

One question - is it necessary to loop through the controls collection to
identify the control, rather than addressing it directly (i.e. For Each
CtlDetail In Me.Section(acPageHeader).Controls)

=========================
'Subroutine to concatenate a label (bold) and a text field (unbold) and
right align
Private Sub PageHeader0_Print(Cancel As Integer, PrintCount As Integer)
Dim CtlDetail As control

strLabel = "Client Ref : " 'Label Description
strField = "Text186" 'Field Name

For Each CtlDetail In Me.Section(acPageHeader).Controls
If CtlDetail.NAME = strField Then
CtlDetail.Visible = False
Me.ScaleMode = TWIPS
intFieldWidth = CtlDetail.Width
Me.FontName = CtlDetail.FontName
Me.FontSize = CtlDetail.FontSize
intTextWidth = TextWidth(CtlDetail)
Me.FontBold = True
intLabelWidth = TextWidth(strLabel)
Me.CurrentX = CtlDetail.Left + intFieldWidth - intLabelWidth -
intTextWidth
Me.CurrentY = CtlDetail.Top + 30 'set to center TNR 11 pt
vertically
Me.Print strLabel;
Me.FontBold = False
Me.Print CtlDetail.Value
End If
Next CtlDetail

End Sub


Douglas J. Steele said:
Is there some reason you can't use two text boxes?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JimP said:
Thanks for the pointer. The following code, while simple, is working -
except that I want to right align the text (Text186). I'm not sure that
is possible. The value for Me.CurrentX seems to force a left align.

Private Sub PageHeader0_Print(Cancel As Integer, PrintCount As Integer)
Me!Text186.Visible = False
With Me
.ScaleMode = TWIPS
.FontBold = True
.CurrentX = Me!Text186.Left
.CurrentY = Me!Text186.Top
Me.Print "Client Ref : ";
.FontBold = False
Me.Print Me!Text186
End With

End Sub


Um, that would make everything in the text box bold, Dave, not just
"LabelName: "

Stephen Lebans has some examples of how to mix Bold and Plain at
http://www.lebans.com/mixbold-plain.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


In design mode, select the label and open the properties dialog.
select the
format property and look for the Font Weight property. Select what
you want
from the dropdown.
--
Dave Hargis, Microsoft Access MVP


:

I have a text field on a report that is the concatenation of a label
and a
field name. How can I bold the label portion? e.g.

Text111 = "LabelName: " & [FieldName]

LabelName portion should print in bold
 
J

JimP

...thank you.

Douglas J. Steele said:
I'm not aware of a reason to loop.

With Me.Controls(strField)
.Visible = False
Me.ScaleMode = TWIPS
intFieldWidth = .Width
Me.FontName = .FontName
Me.FontSize = .FontSize
intTextWidth = TextWidth(Me.Controls(strField))
Me.FontBold = True
intLabelWidth = TextWidth(strLabel)
Me.CurrentX = .Left + intFieldWidth - intLabelWidth - intTextWidth
Me.CurrentY = .Top + 30 'set to center TNR 11 pt vertically
Me.Print strLabel;
Me.FontBold = False
Me.Print .Value
End With

should be sufficient.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JimP said:
No - cosmetically this solution seems to right align better because the
field length varies considerably. The code below is working though.

One question - is it necessary to loop through the controls collection to
identify the control, rather than addressing it directly (i.e. For Each
CtlDetail In Me.Section(acPageHeader).Controls)

=========================
'Subroutine to concatenate a label (bold) and a text field (unbold) and
right align
Private Sub PageHeader0_Print(Cancel As Integer, PrintCount As Integer)
Dim CtlDetail As control

strLabel = "Client Ref : " 'Label Description
strField = "Text186" 'Field Name

For Each CtlDetail In Me.Section(acPageHeader).Controls
If CtlDetail.NAME = strField Then
CtlDetail.Visible = False
Me.ScaleMode = TWIPS
intFieldWidth = CtlDetail.Width
Me.FontName = CtlDetail.FontName
Me.FontSize = CtlDetail.FontSize
intTextWidth = TextWidth(CtlDetail)
Me.FontBold = True
intLabelWidth = TextWidth(strLabel)
Me.CurrentX = CtlDetail.Left + intFieldWidth - intLabelWidth -
intTextWidth
Me.CurrentY = CtlDetail.Top + 30 'set to center TNR 11
pt vertically
Me.Print strLabel;
Me.FontBold = False
Me.Print CtlDetail.Value
End If
Next CtlDetail

End Sub


Douglas J. Steele said:
Is there some reason you can't use two text boxes?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks for the pointer. The following code, while simple, is working -
except that I want to right align the text (Text186). I'm not sure that
is possible. The value for Me.CurrentX seems to force a left align.

Private Sub PageHeader0_Print(Cancel As Integer, PrintCount As Integer)
Me!Text186.Visible = False
With Me
.ScaleMode = TWIPS
.FontBold = True
.CurrentX = Me!Text186.Left
.CurrentY = Me!Text186.Top
Me.Print "Client Ref : ";
.FontBold = False
Me.Print Me!Text186
End With

End Sub


message Um, that would make everything in the text box bold, Dave, not just
"LabelName: "

Stephen Lebans has some examples of how to mix Bold and Plain at
http://www.lebans.com/mixbold-plain.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


In design mode, select the label and open the properties dialog.
select the
format property and look for the Font Weight property. Select what
you want
from the dropdown.
--
Dave Hargis, Microsoft Access MVP


:

I have a text field on a report that is the concatenation of a label
and a
field name. How can I bold the label portion? e.g.

Text111 = "LabelName: " & [FieldName]

LabelName portion should print in bold
 
G

Guest

My answer is based on my complete misunderstanding of the question <g>
--
Dave Hargis, Microsoft Access MVP


Douglas J. Steele said:
Um, that would make everything in the text box bold, Dave, not just
"LabelName: "

Stephen Lebans has some examples of how to mix Bold and Plain at
http://www.lebans.com/mixbold-plain.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Klatuu said:
In design mode, select the label and open the properties dialog. select
the
format property and look for the Font Weight property. Select what you
want
from the dropdown.
--
Dave Hargis, Microsoft Access MVP


JimP said:
I have a text field on a report that is the concatenation of a label and
a
field name. How can I bold the label portion? e.g.

Text111 = "LabelName: " & [FieldName]

LabelName portion should print in bold
 

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

Top