Public Sub UpdateFonts(strOldFont As String, strNewFont As String)
On Error Resume Next
' Warning: this will globally change the selected font across all forms in the database.
' It is strongly recommended that you backup the database before running.
' Original code at https://ss64.com/access/syntax-fonts.html
' Modified by Colin Riddington 07/07/2021 to add additional controls with text & also include reports
Dim dbs As Object
Dim obj As AccessObject
Dim frm As Form
Dim rpt As Report
Dim ctl As Control
Application.Echo False 'turn off screen updating
Set dbs = Application.CurrentProject
' Loop through the AllForms collection.
For Each obj In dbs.AllForms
DoCmd.OpenForm obj.Name, acDesign
Set frm = Forms(obj.Name)
' Loop through the controls on each form
For Each ctl In frm.Controls
' Change the Font of text boxes etc
' Additional controls containing text added by Colin Riddington
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Or ctl.ControlType = acListBox Or ctl.ControlType = acLabel _
Or ctl.ControlType = acCommandButton Or ctl.ControlType = acToggleButton Or ctl.ControlType = acTabCtl Then
If ctl.FontName = strOldFont Then
ctl.FontName = strNewFont
End If
End If
Next
Set ctl = Nothing
' Save the form
DoCmd.Close acForm, obj.Name, acSaveYes
Next obj
' Loop through the AllReports collection.
For Each obj In dbs.AllReports
DoCmd.OpenReport obj.Name, acDesign
Set rpt = Reports(obj.Name)
' Loop through the controls on each report
For Each ctl In rpt.Controls
' Change the Font of text boxes etc
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Or ctl.ControlType = acListBox Or ctl.ControlType = acLabel _
Or ctl.ControlType = acCommandButton Or ctl.ControlType = acToggleButton Or ctl.ControlType = acTabCtl Then
If ctl.FontName = strOldFont Then
ctl.FontName = strNewFont
End If
End If
Next
Set ctl = Nothing
' Save the report
DoCmd.Close acReport, obj.Name, acSaveYes
Next obj
Application.Echo True 'turn on screen updating
MsgBox "All controls using " & strOldFont & " font have been updated to " & strNewFont & " in all forms and reports", vbInformation, "Font update completed"
End Sub