How to Change the Font in Access VBA

Updated April 17, 2017

Microsoft Access's programming language, Visual Basic for Applications (VBA), allows Access 2010 users to change any aspect of Access's appearance. This includes the ability to change font names and other properties for all tables and reports. One step involved in changing a font with Access VBA is identifying the font-related properties of VBA's object model. By using VBA to change a font in Access, you can give your reports and other Access elements a distinctive appearance with text that's easy to read.

Open Access. Click the "Table" icon on the "Create" tab.

Type a few characters in the cell to the right of the "ID" field. The characters you type will appear in Access's default font, Calibri. The VBA program you'll enter next will change that font.

Press "Alt" and "F11" simultaneously to enter the VBA integrated development environment, which is better known as the IDE.

Click the "Insert" menu heading, and then click the "Module" item. This makes a new window for entering your VBA program's statements.

Paste the following code into the code window:

Public Sub setDefaultFont()

SetOption "default font name", "arial"

SetOption "default font size", "16"

End Sub

Run this program by clicking any of its statements and pressing "F5."

Return to Access by pressing "Alt" and "F11" simultaneously again. Create a new table by following steps 1 and 2. This time, the characters you type will be in the font specified in your VBA program -- Arial, size 16 points.

Click any existing table in the navigation pane at screen left, and then click the "Create" menu heading.

Click the "Report" icon on the toolbar to make a new report based on the table you selected in step 8. You'll use another VBA program to change a font in the report.

Click any blank area of the "Detail" section of the new report, and then click "Properties."

Click the "Down" arrow in the "On Format" event of the "Properties" pane at screen right. Click "Event procedure," which tells Access to create a new code module to hold your VBA program. Click the button next to the down arrow to enter that module.

Paste the following statements inside the "Detail_Format" subroutine that Access brings you to. These statements set the font name of a report control called "Field1" to "Courier" and change the font's size to 18 points.

Field1.FontName = "Courier"

Field1.FontSize = 18

Type over the "Field1" text with the name of a control that appears in your report. You can find a field name by looking at the top of any column of the table you chose in step 8 to make a report from. For example, for a table of salespeople, one of the column names might be "Firstname," and others might be "Lastname" or "AvgSalesPerMonth."

Press "Alt" and "F11" simultaneously to return to Access, and then run your VBA code by right-clicking the report's tab and clicking "Report view." The report will appear and display the "Courier" font in the field you indicated in step 12.

Cite this Article A tool to create a citation to reference this article Cite this Article

About the Author

Darrin Koltow wrote about computer software until graphics programs reawakened his lifelong passion of becoming a master designer and draftsman. He has now committed to acquiring the training for a position designing characters, creatures and environments for video games, movies and other entertainment media.