James Hill
James Hill

Reputation: 61812

Change font on all controls on Microsoft Access report

I have a very complex Microsoft Access report. This report is run for multiple customers. I would like to change the font on a subset** of controls on the report (there are tons) for a particular customer, but not for others. Since the font is set at the control level, is it possible to change it programatically?

**The criteria that selects the subset would be based on the current font. For example, I would want to change the font on all controls which currently use Arial.

Upvotes: 0

Views: 7230

Answers (2)

Fionnuala
Fionnuala

Reputation: 91366

How about:

Private Sub Report_Load()
If Me.OpenArgs = "1" Then
    ChangeFont Me
End If
End Sub


Sub ChangeFont(rpt As Report)
Dim ctl As Control

    For Each ctl In rpt.Controls
        If ctl.ControlType = acSubform Then
            ChangeFont ctl.Report
        ElseIf ctl.ControlType = acTextBox Then
            If ctl.FontName = "Calibri" Then

                 ctl.FontName = "Times"
            End If
        End If
    Next
End Sub

Upvotes: 3

ron tornambe
ron tornambe

Reputation: 10780

You can do something like the following:

DoCmd.OpenReport "MyReport", acViewDesign, , , acHidden
For Each ctl In Reports.Item("AmbulanceServices")
  If ctl.FontName = "Arial" Then
    ctl.FontName = "Tahoma"
    ctl.FontSize = 10
  End If
Next
DoCmd.Save acReport, "MyReport"

Upvotes: 1

Related Questions