Reputation: 61812
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
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
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