FontName Property [Access 2003 VBA Language Reference]

You can use the FontName property to specify the font for text in the following situations:

  • When displaying or printing controls on forms and reports.

  • When using the Print method on a report.

Read/write String.


expression Required. An expression that returns one of the objects in the Applies To list.


The FontName property setting is the name of the font that the text is displayed in.

For controls on forms and reports, you can set this property by using the property sheet , a macro , or Visual Basic .

You can also set this property by clicking the Font box on the Formatting (Form/Report) toolbar.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For reports, you can set this property only in an event procedure or in a macro specified by the OnPrintevent property setting.

In Visual Basic, you set the FontName property by using a string expression that is the name of the desired font.

Font availability depends on your system and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.


The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.

Private Sub Detail_Format(Cancel As Integer, _
        FormatCount As Integer)
    Dim rpt as Report
    Dim strMessage As String
    Dim intHorSize As Integer, intVerSize As Integer

    Set rpt = Me
    strMessage = "DisplayMessage"
    With rpt
        'Set scale to pixels, and set FontName and
        'FontSize properties.
        .ScaleMode = 3
        .FontName = "Courier"
        .FontSize = 24
    End With
    ' Horizontal width.
    intHorSize = Rpt.TextWidth(strMessage)
    ' Vertical height.
    intVerSize = Rpt.TextHeight(strMessage)
    ' Calculate location of text to be displayed.
    Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
    Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
    ' Print text on Report object.
    Rpt.Print strMessage
End Sub

Applies to | ComboBox Object | CommandButton Object | Label Object | ListBox Object | Report Object | TabControl Collection | TextBox Object | ToggleButton Object

See Also | FontBold Property | FontItalic Property | FontSize Property | FontUnderline Property | FontWeight Property