Reader Huy Truong wrote in with the following question (shared with permission):
I wonder if you could write a QuickTip on making Access default to a font? For example, in Access 2016, the default font for all objects is Calibri but I want to change it to Consolas, as that'd help my customers differentiate between 0 (with a slash like this ø) and O.
Great question, Huy!
Setting Default Fonts by Form and Control Type
Let's start with the lowest level and work our way up.
- Go into Form Design mode
- Click once on the Text Box button in the Controls ribbon group
- Set the default properties you want for Text Box controls on this form
- Repeat steps 2 and 3 for the other control types (e.g., Labels, Command Buttons, etc.)
This will only work for the current form you are editing. Any new forms you create will go back to the original database defaults. So, while this is good information to know, it's not an ideal solution–especially if you are trying to maintain consistency throughout your user interface.
Setting Default Fonts for All Forms (and Reports)
- Create a new form
- Follow the steps above and set the Font Name to "Consolas" for the Default Text Box
- Save the form as "ConsolasTextBoxes" and close it
- File > Options > Object Designers > Form Template:
- Click [OK] to close the Access Options dialog
- Create a new form
- Add a text box to the form...the font name defaults to Consolas
In step 2, you can set additional properties for additional control types.
You can also repeat steps 1-7 replacing the word "Form" with "Report" to create and assign an application-wide Report template.
This might seem like the perfect solution, but there are two big drawbacks:
- Buggy behavior
- You can only define a single template
I honestly don't remember the nature of the buggy behavior. It occurred early in my Access development career when I was doing a lot of my development with and for Access 2000. The buggy behavior may have been fixed by now. I never found out because the second drawback is worse than the first.
I do not use this method.
Multiple Form and Report Templates
If you think about it, defining a Form and/or Report template does not get you anything you couldn't get by copying and pasting an existing form or report.
- Create a form
- Set its Default View to "Single Form"
- Set Record Selectors to "No"
- Set Navigation Buttons to "No"
- Save the form as "_Unbound_Template" and close it
- Create another form
- Set its Default View to "Continuous Forms"
- Set the Default Text Box's Add Colon property to "No"
- Set the Default Combo Box's Add Colon property to "No"
- Save the form as "_Continuous_Template" and close it
To create a new unbound form, select the "_Unbound_Template" form, then press [Ctrl] + [C] (copy) followed by [Ctrl] + [V] (paste). Enter the name you want for your new form and click [OK]. For a new continuous form, follow the same steps but copy and paste the "_Continuous_Template" form.
This approach is easy, and it completely avoids the two drawbacks of the template approach.
This is the technique I would recommend for most users.
Make Global Style Changes with Themes
One big downside to all of the approaches so far is that they only affect future forms.
If we want to make widespread changes to existing forms, those techniques won't help. This is where Access Themes come into play. By modifying the default theme style to use a new font, you can potentially apply changes across the entire front-end application.
I know at least one Access developer, Peter Cole, who swears by this approach. If this interests you, I recommend you contact Peter or at least check out his presentation and/or Access Theme tool (not publicly available as of writing).
I've avoided this approach over the years for a few reasons:
- Changing a font globally could cause some control values to get cut off
- You must use theme colors instead of choosing from the entire color palette
- I don't like the idea of changing things that are already tested and working
Building New Forms (and Reports) in Code
The technique that I prefer is to create and customize forms using VBA.
Here's the subroutine declaration:
Sub DesignNewForm(Optional ByVal IsContinuous As Boolean = False, _ Optional ByVal IsUnbound As Boolean = False, _ Optional ByVal IsPreview As Boolean = False, _ Optional ByVal IsGetForm As Boolean = False, _ Optional ByVal IsLookup As Boolean = False, _ Optional ByVal IsUnboundAddForm As Boolean = False, _ Optional ByVal InsertCode As Boolean = True)
As you can see, I use this one function to create forms for a wide variety of uses.
Here's an excerpt of the code that powers the function:
Const TwipsPerInch As Long = 1440 Dim Frm As Form Set Frm = CreateForm With Frm .GridX = 16 .GridY = 16 .Width = 4 * TwipsPerInch If Not (IsPreview Or IsGetForm) Then DoCmd.RunCommand acCmdFormHdrFtr .DividingLines = True End If With .DefaultControl(acCommandButton) .FontName = "Verdana" .FontSize = "10" End With With DefaultControl(acTextBox) .FontName = "Consolas" .FontSize = "10" End With DoCmd.Restore 'https://nolongerset.com/fun-with-form-windows/ FillAccessWindow .hWnd, , , 0.5, 0.5 End With
My actual code has grown quite a bit over the years. It is very particular to our design aesthetic. As you almost certainly will have a different aesthetic than mine, including all of my code would be a distraction.
The above code should be enough to get you started building your own custom form template code.