J
jemedwards via AccessMonster.com
Thanks to two responses to my first post at
http://www.accessmonster.com/Uwe/Fo...2-Concatenating-Fields-Showing-Different-Font
I received guidance on my situation (of which I didn't know was a popular
question) how to make part of a control bold and the other part normal.
I work at an agency that has our PCs locked down tight so I'm unable to
download or copy any programs/files onto the PC otherwise I would try and
work with Mr. Lebans Rich Text control that on his website.
So I copied the Lebans code from the Lady database into my database and
attempted to modify it to work with my database but I'm having problems with
it. I hope that it's ok that I've copied it here with a request for someone
to run the debugger and what my problem is. The debugger keeps giving me
different errors regarding "with", "end with" and "endif". I don't
understand the Visual Basic program so I don't understand about debugging.
I must add that I've just taught myself Access (using Access 2003) and I know
nothing about Visual Basic which works with this code.
In Mr. Lebans code I only changed the name of the two fields used in the
original code (assignment instead of firstname and agencyname instead of
lastname). I also changed the name of the concatenated label to
agencynameandassignment instead of tdlady. Additionally I tried to remove
the margins from the original code because I do not need a box drawn around
the concatenated field.
Thank you for any assistance in helping me with my first little database.
=============================================================
Option Compare Database
Option Explicit
' **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 strassignment As String
Dim stragencyname 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 agencynameandassignment. 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
' =[agencyname]&" "&[assignment]
' 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.agencyname = "agencynameandassignment" Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
stragencyname = Left(.Value, intPosition - 1)
strassignment = Mid(.Value, intPosition + 2)
'Debug.Print stragencyname
'Debug.Print strassignment
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 agencyname - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
' For some reason must be Me.Print not .Print
Me.Print stragencyname;
Me.Print ", ";
' Reset Font-> NO Bold for assignment
.FontBold = False
'.FontItalic = False
Me.Print strassignment
' 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
Next
' Cleanup
Set CtlDetail = Nothing
End Sub
http://www.accessmonster.com/Uwe/Fo...2-Concatenating-Fields-Showing-Different-Font
I received guidance on my situation (of which I didn't know was a popular
question) how to make part of a control bold and the other part normal.
I work at an agency that has our PCs locked down tight so I'm unable to
download or copy any programs/files onto the PC otherwise I would try and
work with Mr. Lebans Rich Text control that on his website.
So I copied the Lebans code from the Lady database into my database and
attempted to modify it to work with my database but I'm having problems with
it. I hope that it's ok that I've copied it here with a request for someone
to run the debugger and what my problem is. The debugger keeps giving me
different errors regarding "with", "end with" and "endif". I don't
understand the Visual Basic program so I don't understand about debugging.
I must add that I've just taught myself Access (using Access 2003) and I know
nothing about Visual Basic which works with this code.
In Mr. Lebans code I only changed the name of the two fields used in the
original code (assignment instead of firstname and agencyname instead of
lastname). I also changed the name of the concatenated label to
agencynameandassignment instead of tdlady. Additionally I tried to remove
the margins from the original code because I do not need a box drawn around
the concatenated field.
Thank you for any assistance in helping me with my first little database.
=============================================================
Option Compare Database
Option Explicit
' **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 strassignment As String
Dim stragencyname 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 agencynameandassignment. 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
' =[agencyname]&" "&[assignment]
' 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.agencyname = "agencynameandassignment" Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
stragencyname = Left(.Value, intPosition - 1)
strassignment = Mid(.Value, intPosition + 2)
'Debug.Print stragencyname
'Debug.Print strassignment
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 agencyname - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
' For some reason must be Me.Print not .Print
Me.Print stragencyname;
Me.Print ", ";
' Reset Font-> NO Bold for assignment
.FontBold = False
'.FontItalic = False
Me.Print strassignment
' 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
Next
' Cleanup
Set CtlDetail = Nothing
End Sub