DatasheetFontName, DatasheetFontHeight Properties

Applies To   Form object, QueryDef object, TableDef object.

Description

You can use the DatasheetFontName and DatasheetFontHeight properties to specify the font and the font point size used to display and print field names and data in Datasheet view.

Note The DatasheetFontName and DatasheetFontHeight properties apply to all fields in Datasheet view and to form controls when the form is in Datasheet view.

Setting

You can set these properties by selecting the font name from the Font box or font size from the Font Size box on the Formatting (Datasheet) toolbar.

You can also set these properties with the Font and Size boxes in the Font dialog box, available by clicking Font on the Format menu in Datasheet view.

Remarks

For the DatasheetFontName property, the font names you can specify depend on the fonts installed on your system and for your printer. If you specify a font that your system can't display or that isn't installed, Microsoft Windows will substitute a similar font.

For the DatasheetFontHeight property, the font size you specify must be valid for the font specified by the DatasheetFontName property. For example, MS Sans Serif is available only in sizes 8, 10, 12, 14, 18, and 24 points.

You can set the default DatasheetFontName and DatasheetFontHeight properties by using the settings under Default Font on the Datasheet tab of the Options dialog box, available by clicking Options on the Tools menu.

The following table contains the properties that do not exist in the Properties collection for TableDef or QueryDef objects until you add them using the CreateProperty method or set them using the Formatting (Datasheet) toolbar.

  • DatasheetBackColor
  • DatasheetCellsEffect
  • DatasheetFontHeight*

DatasheetFontItalic*

  • DatasheetFontName*
  • DatasheetFontUnderline*
  • DatasheetFontWeight*
  • DatasheetForeColor*
  • DatasheetGridlinesBehavior
  • DatasheetGridlinesColor

Note When you add or set any property listed with an asterisk, Microsoft Access automatically adds all the properties listed with an asterisk to the Properties collection.

See Also   BackColor property, DatasheetBackColor, DatasheetForeColor properties, DatasheetCellsEffect property, DatasheetFontItalic, DatasheetFontUnderline properties, DatasheetFontWeight property, DatasheetGridlinesBehavior property, DatasheetGridlinesColor property, FillColor property.

Example

The following example sets the font to MS Serif, the font size to 10 points, and the font weight to medium (500) in Datasheet view of the Products table.

To set these properties, the example uses the SetTableProperty procedure, which is shown in the DatasheetFontItalic, DatasheetFontUnderline properties example.

Dim dbs As Database, tdfProducts As TableDef
Set dbs = CurrentDb
Set tdfProducts = dbs!Products
SetTableProperty tdfProducts, "DatasheetFontName", dbText, "MS Serif"
SetTableProperty tdfProducts, "DatasheetFontHeight", dbInteger, 10
SetTableProperty tdfProducts, "DatasheetFontWeight", dbInteger, 500
The next example makes the same changes as the preceding example in Datasheet view of the open Products form.

Forms!Products.DatasheetFontName = "MS Serif"
Forms!Products.DatasheetFontHeight = 10
Forms!Products.DatasheetFontWeight = 500