DatasheetFontItalic, DatasheetFontUnderline Properties 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