DatasheetFontItalic Property

Microsoft Access Visual Basic

expression.DatasheetFontItalic

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

The DatasheetFontItalic property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.

This property is only available in Visual Basic within a Microsoft Access database (.mdb).

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

Setting Description
True The text is italicized.
False (Default) The text isn't italicized.

Note  You can set this property by clicking Italic on the Formatting (Datasheet) toolbar.

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

The following table contains the properties that don't exist in the DAO Properties collection of until you set them by using the Formatting (Datasheet) toolbar or you can add them in an Access database (.mdb) by using the CreateProperty method and append it to the DAO Properties collection.

DatasheetFontItalic * DatasheetForeColor *
DatasheetFontHeight * DatasheetBackColor
DatasheetFontName * DatasheetGridlinesColor
DatasheetFontUnderline * DatasheetGridlinesBehavior
DatasheetFontWeight * DatasheetCellsEffect

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 of the database.

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 Object, objProducts As Object
Const DB_Boolean As Long = 1
Set dbs = CurrentDb
Set objProducts = dbs![Products]
SetTableProperty objProducts, "DatasheetFontItalic", DB_Boolean, True
SetTableProperty objProducts, "DatasheetFontUnderline", DB_Boolean, True

Sub SetTableProperty(objTableObj As Object, 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 Variant
    On Error Resume Next                ' Don't trap errors.
    objTableObj.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 '" & objTableObj.Name & "'", 48, "SetTableProperty"
        Else
            On Error GoTo 0
            Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
                intPropertyType, varPropertyValue)
            objTableObj.Properties.Append prpProperty
        End If
    End If
    objTableObj.Properties.Refresh
End Sub