How to Change the Font in Access VBA

Written by darrin koltow
  • Share
  • Tweet
  • Share
  • Email

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.

Skill level:

Other People Are Reading


  1. 1

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

  2. 2

    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.

  3. 3

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

  4. 4

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

  5. 5

    Paste the following code into the code window:

    Public Sub setDefaultFont()

    SetOption "default font name", "arial"

    SetOption "default font size", "16"

    End Sub

  6. 6

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

  7. 7

    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.

  8. 8

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

  9. 9

    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.

  10. 10

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

  11. 11

    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.

  12. 12

    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

  13. 13

    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."

  14. 14

    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.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.