简体   繁体   中英

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.

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

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM