Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #9383

Re: Change Fonts Mid-Field?

From "Phil" <phil@stantonfamily.co.uk>
Newsgroups comp.databases.ms-access
Subject Re: Change Fonts Mid-Field?
Date 2014-05-14 16:34 +0100
Organization Aioe.org NNTP Server
Message-ID <ll02et$3el$1@speranza.aioe.org> (permalink)
References <4f6d9e49-61f9-479b-9d03-659085023d2d@googlegroups.com>

Show all headers | View raw


On 14/05/2014 15:36:25, BrianDP wrote:
> This is a stretch, and I can't think of any way to do this- BUT, On an acc
> ess report, lets say we have ONE field, and it starts off in Courier, but
> m id way through the field, Say after the 10th character or something, I
> want to switch the type face to Ariel, is there any way to do this? Maybe
> with Escape codes or something?
> 
> I told them I didn't think it was possible.
> 
> Thanks.
> 
> -Brian P.
> 

Yes, it can be done, thanks to Stephen Lebans

I have a field called MemName which is a Last Name followed by a comma and
space followed by first name This code splits the field on the comma. and
prints the last name in Red Courier Bold 16 point and the First name in Black
Broadway 8 point. If the 2 fonts are too dissimilar, tou will get an
alignment problem. Note that the field name to be formated MUST be changed in
the Detail_Print event

Option Compare Database
Option Explicit

Sub FormatField(FieldName As String, Delimiter As String)

 ' **START CODE
    ' Written by Stephen Lebans 1999
    ' Stephen@lebans.com
    ' www.lebans.com
    
    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 tblady. 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
    ' =[LastName]&", "&[FirstName]
    ' 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 = FieldName Then
            With CtlDetail
                .Visible = False
                intPosition = InStr(1, .Value, Delimiter)
                strLast = Left(.Value, intPosition - 1)
                strFirst = Mid(.Value, intPosition + 1)
                '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
                .FontSize = 16
                .FontName = "Courier"
                .ForeColor = 255                ' Red
                '.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 strLast;
                Me.Print ", ";
                
                ' Reset Font-> NO Bold for FirstName
                .FontBold = False
                '.FontItalic = False
                .FontSize = 8
                .FontName = "Broadway"
                .ForeColor = 0                  ' Black
                Me.Print strFirst
    
    
            ' Restore Reports original Font settings
            .ScaleMode = oldScaleMode
            .FontBold = oldFontBold
            .FontItalic = oldFontItalic
            .FontName = oldFontName
            .FontSize = oldfontsize
            .ForeColor = oldForeColor
        End With
    End If
        Next
    
    ' Cleanup
    Set CtlDetail = Nothing

End Sub

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

    FormatField "MemName", ","
    
End Sub

Phil

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Change Fonts Mid-Field? BrianDP <bdp222@gmail.com> - 2014-05-14 07:36 -0700
  Re: Change Fonts Mid-Field? "Ron Paii" <None@none.com> - 2014-05-14 10:14 -0500
    Re: Change Fonts Mid-Field? "Ron Paii" <None@none.com> - 2014-05-15 09:40 -0500
  Re: Change Fonts Mid-Field? "Phil" <phil@stantonfamily.co.uk> - 2014-05-14 16:34 +0100
  Re: Change Fonts Mid-Field? DFS <nospam@dfs.com> - 2014-05-14 11:40 -0400
  Re: Change Fonts Mid-Field? BrianDP <bdp222@gmail.com> - 2014-05-14 12:10 -0700
    Re: Change Fonts Mid-Field? Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-05-15 06:45 -0700
    Re: Change Fonts Mid-Field? "Albert D. Kallal" <PleaseNOSpamkallal@msn.com> - 2014-05-15 10:44 -0600

csiph-web