DatasheetFontItalic, DatasheetFontUnderline Properties

Applies To   Form object, QueryDef object, TableDef object.

Description

You can use the DatasheetFontItalic and DatasheetFontUnderline properties to specify an italic or underlined appearance for field names and data in Datasheet view.

Note The DatasheetFontItalic and DatasheetFontUnderline 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 clicking the Italic button or the Underline button on the Formatting (Datasheet) toolbar.

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

In Visual Basic, the DatasheetFontItalic property uses the following settings.

Setting

Description

True (–1)

The text is italic.

False (0)

(Default) The text isn't italic.


In Visual Basic, the DatasheetFontUnderline property uses the following settings.

Setting

Description

True

The text is underlined.

False

(Default) The text isn't underlined.


In Visual Basic, these property settings are Boolean values.

Remarks

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, DatasheetFontName, DatasheetFontHeight properties, DatasheetFontWeight property, DatasheetGridlinesBehavior property, DatasheetGridlinesColor property, ForeColor property.

Example

The following example displays the data and field names in Datasheet view of the Products form as italic and underlined.

Forms![Products].DatasheetFontItalic = True
Forms![Products].DatasheetFontUnderline = True
The next example displays the data and field names in Datasheet view of the Products table as italic and underlined.

To set the DatasheetFontItalic and DatasheetFontUnderline properties, the example uses the SetTableProperty procedure, which is in the database's standard module.

Dim dbs As Database, tdfProducts As TableDef
Set dbs = CurrentDb
Set tdfProducts = dbs![Products]
SetTableProperty tdfProducts, "DatasheetFontItalic", dbBoolean, True
SetTableProperty tdfProducts, "DatasheetFontUnderline", dbBoolean, True

Sub SetTableProperty(tdfTableObj As TableDef, strPropertyName As String, _
        intPropertyType As Integer, varPropertyValue As Variant)
    ' Set Microsoft Access-defined table property without causing
    ' nonrecoverable run-time error.
    Const conErrPropertyNotFound = 3270
    Dim prpProperty As Property
    On Error Resume Next                ' Don't trap errors.
    tdfTableObj.Properties(strPropertyName) = varPropertyValue
    If Err <> 0 Then                    ' Error occurred when value set.
        If Err <> conErrPropertyNotFound Then
            On Error GoTo 0
            MsgBox "Couldn't set property '" & strPropertyName _
                & "' on table '" & tdfTableObj.Name & "'", 48, _
                "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = tdfTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            tdfTableObj.Properties.Append prpProperty
        End If
    End If
    tdfTableObj.Properties.Refresh
End Sub