Using Detail.Print

  • Thread starter Thread starter Laurel
  • Start date Start date
L

Laurel

I got some great code from a site recommended by Al Campagna (see post
"Slide to Left" for specific URL if needed.) It allows me to interrupt the
print process and set part of the string to be printed to bold. My HUGE
problem is that after finding this wonderful code and getting my report all
set up, I find that the controls that this code acts on don't show up on the
printed page - that is the hardcopy, although they show up nicely on the
screen. Can anyone help?

' **START CODE
' Written by Stephen Lebans 1999
' (e-mail address removed)
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strFirst As String
Dim strLast As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .FontSize

oldScaleMode = .ScaleMode
End With

' Set Margin for Border we will draw
' around your concatenated control.
intMargin = 60

' Remember for this sample I am
' naming your control txtFirstLine. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[Last Name]&", "&[First Name]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If (CtlDetail.Name = "txtFirstLine") Or (CtlDetail.Name =
"txtSecondLine") Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
If intPosition = 0 Then
GoTo NextCTL
End If
strLast = Left(.Value, intPosition - 1)
strFirst = Mid(.Value, intPosition + 2)
'Debug.Print strLast
'Debug.Print strFirst

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

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

' Create desired Font settings
' for the Last Name - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
If CtlDetail.Name = "txtSecondLine" Then
.CurrentY = 250
End If
' For some reason must be Me.Print not .Print
Me.Print strLast;
Me.Print ", ";

' Reset Font-> NO Bold for First Name
.FontBold = False
'.FontItalic = False
Me.Print strFirst


' Restore Reports original Font settings
..ScaleMode = oldScaleMode
..FontBold = oldFontBold
..FontItalic = oldFontItalic
..FontName = oldFontName
..FontSize = oldfontsize
..ForeColor = oldForeColor

End With

' With CtlDetail
' 'While we are here lets draw a box around each field
' Me.Line ((.Left - intMargin), (.Top - intMargin))-Step((.Width +
(intMargin * 2)), (.Height + (intMargin * 2))), 0, B
' End With
End If
NextCTL:
Next

' Cleanup
Set CtlDetail = Nothing
End Sub
 
I'm sure Stephen tested that it works with hard copy too.

Try changing fonts to see whether it makes a difference.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Laurel said:
I got some great code from a site recommended by Al Campagna (see post
"Slide to Left" for specific URL if needed.) It allows me to interrupt the
print process and set part of the string to be printed to bold. My HUGE
problem is that after finding this wonderful code and getting my report all
set up, I find that the controls that this code acts on don't show up on
the printed page - that is the hardcopy, although they show up nicely on
the screen. Can anyone help?

' **START CODE
' Written by Stephen Lebans 1999
' (e-mail address removed)
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strFirst As String
Dim strLast As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .FontSize

oldScaleMode = .ScaleMode
End With

' Set Margin for Border we will draw
' around your concatenated control.
intMargin = 60

' Remember for this sample I am
' naming your control txtFirstLine. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[Last Name]&", "&[First Name]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If (CtlDetail.Name = "txtFirstLine") Or (CtlDetail.Name =
"txtSecondLine") Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
If intPosition = 0 Then
GoTo NextCTL
End If
strLast = Left(.Value, intPosition - 1)
strFirst = Mid(.Value, intPosition + 2)
'Debug.Print strLast
'Debug.Print strFirst

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

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

' Create desired Font settings
' for the Last Name - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
If CtlDetail.Name = "txtSecondLine" Then
.CurrentY = 250
End If
' For some reason must be Me.Print not .Print
Me.Print strLast;
Me.Print ", ";

' Reset Font-> NO Bold for First Name
.FontBold = False
'.FontItalic = False
Me.Print strFirst


' Restore Reports original Font settings
.ScaleMode = oldScaleMode
.FontBold = oldFontBold
.FontItalic = oldFontItalic
.FontName = oldFontName
.FontSize = oldfontsize
.ForeColor = oldForeColor

End With

' With CtlDetail
' 'While we are here lets draw a box around each field
' Me.Line ((.Left - intMargin), (.Top - intMargin))-Step((.Width +
(intMargin * 2)), (.Height + (intMargin * 2))), 0, B
' End With
End If
NextCTL:
Next

' Cleanup
Set CtlDetail = Nothing
End Sub
 
??? Everything else in the report is the same font. Everything else
prints.
Yes, I'm sure it has worked on hardcopy. That's why I'm hoping for advice
on what to do.

Douglas J. Steele said:
I'm sure Stephen tested that it works with hard copy too.

Try changing fonts to see whether it makes a difference.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Laurel said:
I got some great code from a site recommended by Al Campagna (see post
"Slide to Left" for specific URL if needed.) It allows me to interrupt
the print process and set part of the string to be printed to bold. My
HUGE problem is that after finding this wonderful code and getting my
report all set up, I find that the controls that this code acts on don't
show up on the printed page - that is the hardcopy, although they show up
nicely on the screen. Can anyone help?

' **START CODE
' Written by Stephen Lebans 1999
' (e-mail address removed)
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strFirst As String
Dim strLast As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .FontSize

oldScaleMode = .ScaleMode
End With

' Set Margin for Border we will draw
' around your concatenated control.
intMargin = 60

' Remember for this sample I am
' naming your control txtFirstLine. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[Last Name]&", "&[First Name]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If (CtlDetail.Name = "txtFirstLine") Or (CtlDetail.Name =
"txtSecondLine") Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
If intPosition = 0 Then
GoTo NextCTL
End If
strLast = Left(.Value, intPosition - 1)
strFirst = Mid(.Value, intPosition + 2)
'Debug.Print strLast
'Debug.Print strFirst

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

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

' Create desired Font settings
' for the Last Name - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
If CtlDetail.Name = "txtSecondLine" Then
.CurrentY = 250
End If
' For some reason must be Me.Print not .Print
Me.Print strLast;
Me.Print ", ";

' Reset Font-> NO Bold for First Name
.FontBold = False
'.FontItalic = False
Me.Print strFirst


' Restore Reports original Font settings
.ScaleMode = oldScaleMode
.FontBold = oldFontBold
.FontItalic = oldFontItalic
.FontName = oldFontName
.FontSize = oldfontsize
.ForeColor = oldForeColor

End With

' With CtlDetail
' 'While we are here lets draw a box around each field
' Me.Line ((.Left - intMargin), (.Top - intMargin))-Step((.Width
+ (intMargin * 2)), (.Height + (intMargin * 2))), 0, B
' End With
End If
NextCTL:
Next

' Cleanup
Set CtlDetail = Nothing
End Sub
 
AHH!!! I've been buried in this so long I got confused. The problem is
limited to sending the output to Word and then printing. Not nearly so
critical, but, still, critical enough. I've found that sending output to
Word is often flakey. Any ideas on that front?

Laurel said:
I got some great code from a site recommended by Al Campagna (see post
"Slide to Left" for specific URL if needed.) It allows me to interrupt the
print process and set part of the string to be printed to bold. My HUGE
problem is that after finding this wonderful code and getting my report all
set up, I find that the controls that this code acts on don't show up on
the printed page - that is the hardcopy, although they show up nicely on
the screen. Can anyone help?

' **START CODE
' Written by Stephen Lebans 1999
' (e-mail address removed)
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strFirst As String
Dim strLast As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .FontSize

oldScaleMode = .ScaleMode
End With

' Set Margin for Border we will draw
' around your concatenated control.
intMargin = 60

' Remember for this sample I am
' naming your control txtFirstLine. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[Last Name]&", "&[First Name]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If (CtlDetail.Name = "txtFirstLine") Or (CtlDetail.Name =
"txtSecondLine") Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
If intPosition = 0 Then
GoTo NextCTL
End If
strLast = Left(.Value, intPosition - 1)
strFirst = Mid(.Value, intPosition + 2)
'Debug.Print strLast
'Debug.Print strFirst

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

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

' Create desired Font settings
' for the Last Name - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
If CtlDetail.Name = "txtSecondLine" Then
.CurrentY = 250
End If
' For some reason must be Me.Print not .Print
Me.Print strLast;
Me.Print ", ";

' Reset Font-> NO Bold for First Name
.FontBold = False
'.FontItalic = False
Me.Print strFirst


' Restore Reports original Font settings
.ScaleMode = oldScaleMode
.FontBold = oldFontBold
.FontItalic = oldFontItalic
.FontName = oldFontName
.FontSize = oldfontsize
.ForeColor = oldForeColor

End With

' With CtlDetail
' 'While we are here lets draw a box around each field
' Me.Line ((.Left - intMargin), (.Top - intMargin))-Step((.Width +
(intMargin * 2)), (.Height + (intMargin * 2))), 0, B
' End With
End If
NextCTL:
Next

' Cleanup
Set CtlDetail = Nothing
End Sub
 
Given that sending output to Word actually uses RTF, I doubt there's much
you'll be able to do.

If it's critical, you'll probably have to use Automation to open the report
you exported and reformat it.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Laurel said:
AHH!!! I've been buried in this so long I got confused. The problem is
limited to sending the output to Word and then printing. Not nearly so
critical, but, still, critical enough. I've found that sending output to
Word is often flakey. Any ideas on that front?

Laurel said:
I got some great code from a site recommended by Al Campagna (see post
"Slide to Left" for specific URL if needed.) It allows me to interrupt
the print process and set part of the string to be printed to bold. My
HUGE problem is that after finding this wonderful code and getting my
report all set up, I find that the controls that this code acts on don't
show up on the printed page - that is the hardcopy, although they show up
nicely on the screen. Can anyone help?

' **START CODE
' Written by Stephen Lebans 1999
' (e-mail address removed)
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strFirst As String
Dim strLast As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .FontSize

oldScaleMode = .ScaleMode
End With

' Set Margin for Border we will draw
' around your concatenated control.
intMargin = 60

' Remember for this sample I am
' naming your control txtFirstLine. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[Last Name]&", "&[First Name]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If (CtlDetail.Name = "txtFirstLine") Or (CtlDetail.Name =
"txtSecondLine") Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
If intPosition = 0 Then
GoTo NextCTL
End If
strLast = Left(.Value, intPosition - 1)
strFirst = Mid(.Value, intPosition + 2)
'Debug.Print strLast
'Debug.Print strFirst

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

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

' Create desired Font settings
' for the Last Name - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
If CtlDetail.Name = "txtSecondLine" Then
.CurrentY = 250
End If
' For some reason must be Me.Print not .Print
Me.Print strLast;
Me.Print ", ";

' Reset Font-> NO Bold for First Name
.FontBold = False
'.FontItalic = False
Me.Print strFirst


' Restore Reports original Font settings
.ScaleMode = oldScaleMode
.FontBold = oldFontBold
.FontItalic = oldFontItalic
.FontName = oldFontName
.FontSize = oldfontsize
.ForeColor = oldForeColor

End With

' With CtlDetail
' 'While we are here lets draw a box around each field
' Me.Line ((.Left - intMargin), (.Top - intMargin))-Step((.Width
+ (intMargin * 2)), (.Height + (intMargin * 2))), 0, B
' End With
End If
NextCTL:
Next

' Cleanup
Set CtlDetail = Nothing
End Sub
 
What is Automation? Is it something I can download?

Douglas J. Steele said:
Given that sending output to Word actually uses RTF, I doubt there's much
you'll be able to do.

If it's critical, you'll probably have to use Automation to open the
report you exported and reformat it.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Laurel said:
AHH!!! I've been buried in this so long I got confused. The problem is
limited to sending the output to Word and then printing. Not nearly so
critical, but, still, critical enough. I've found that sending output to
Word is often flakey. Any ideas on that front?

Laurel said:
I got some great code from a site recommended by Al Campagna (see post
"Slide to Left" for specific URL if needed.) It allows me to interrupt
the print process and set part of the string to be printed to bold. My
HUGE problem is that after finding this wonderful code and getting my
report all set up, I find that the controls that this code acts on don't
show up on the printed page - that is the hardcopy, although they show up
nicely on the screen. Can anyone help?

' **START CODE
' Written by Stephen Lebans 1999
' (e-mail address removed)
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strFirst As String
Dim strLast As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .FontSize

oldScaleMode = .ScaleMode
End With

' Set Margin for Border we will draw
' around your concatenated control.
intMargin = 60

' Remember for this sample I am
' naming your control txtFirstLine. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[Last Name]&", "&[First Name]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If (CtlDetail.Name = "txtFirstLine") Or (CtlDetail.Name =
"txtSecondLine") Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
If intPosition = 0 Then
GoTo NextCTL
End If
strLast = Left(.Value, intPosition - 1)
strFirst = Mid(.Value, intPosition + 2)
'Debug.Print strLast
'Debug.Print strFirst

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

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

' Create desired Font settings
' for the Last Name - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
If CtlDetail.Name = "txtSecondLine" Then
.CurrentY = 250
End If
' For some reason must be Me.Print not .Print
Me.Print strLast;
Me.Print ", ";

' Reset Font-> NO Bold for First Name
.FontBold = False
'.FontItalic = False
Me.Print strFirst


' Restore Reports original Font settings
.ScaleMode = oldScaleMode
.FontBold = oldFontBold
.FontItalic = oldFontItalic
.FontName = oldFontName
.FontSize = oldfontsize
.ForeColor = oldForeColor

End With

' With CtlDetail
' 'While we are here lets draw a box around each field
' Me.Line ((.Left - intMargin), (.Top - intMargin))-Step((.Width
+ (intMargin * 2)), (.Height + (intMargin * 2))), 0, B
' End With
End If
NextCTL:
Next

' Cleanup
Set CtlDetail = Nothing
End Sub
 
"Automation" is a term used to describe the programming techniques to
control one application from another. Not all applications expose themselves
to Automation, but all of the Office apps do. While it's old,
http://support.microsoft.com/kb/260410/en-us will give you an introduction
to the topic.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Laurel said:
What is Automation? Is it something I can download?

Douglas J. Steele said:
Given that sending output to Word actually uses RTF, I doubt there's much
you'll be able to do.

If it's critical, you'll probably have to use Automation to open the
report you exported and reformat it.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Laurel said:
AHH!!! I've been buried in this so long I got confused. The problem is
limited to sending the output to Word and then printing. Not nearly so
critical, but, still, critical enough. I've found that sending output
to Word is often flakey. Any ideas on that front?

I got some great code from a site recommended by Al Campagna (see post
"Slide to Left" for specific URL if needed.) It allows me to interrupt
the print process and set part of the string to be printed to bold. My
HUGE problem is that after finding this wonderful code and getting my
report all set up, I find that the controls that this code acts on don't
show up on the printed page - that is the hardcopy, although they show
up nicely on the screen. Can anyone help?

' **START CODE
' Written by Stephen Lebans 1999
' (e-mail address removed)
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strFirst As String
Dim strLast As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .FontSize

oldScaleMode = .ScaleMode
End With

' Set Margin for Border we will draw
' around your concatenated control.
intMargin = 60

' Remember for this sample I am
' naming your control txtFirstLine. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[Last Name]&", "&[First Name]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If (CtlDetail.Name = "txtFirstLine") Or (CtlDetail.Name =
"txtSecondLine") Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
If intPosition = 0 Then
GoTo NextCTL
End If
strLast = Left(.Value, intPosition - 1)
strFirst = Mid(.Value, intPosition + 2)
'Debug.Print strLast
'Debug.Print strFirst

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

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

' Create desired Font settings
' for the Last Name - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
If CtlDetail.Name = "txtSecondLine" Then
.CurrentY = 250
End If
' For some reason must be Me.Print not .Print
Me.Print strLast;
Me.Print ", ";

' Reset Font-> NO Bold for First Name
.FontBold = False
'.FontItalic = False
Me.Print strFirst


' Restore Reports original Font settings
.ScaleMode = oldScaleMode
.FontBold = oldFontBold
.FontItalic = oldFontItalic
.FontName = oldFontName
.FontSize = oldfontsize
.ForeColor = oldForeColor

End With

' With CtlDetail
' 'While we are here lets draw a box around each field
' Me.Line ((.Left - intMargin), (.Top -
intMargin))-Step((.Width + (intMargin * 2)), (.Height + (intMargin *
2))), 0, B
' End With
End If
NextCTL:
Next

' Cleanup
Set CtlDetail = Nothing
End Sub
 
Back
Top