Form.DatasheetFontItalic Property (Access)
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Form.DatasheetFontItalic Property (Access)

You can use the DatasheetFontItalic property to specify an italicized appearance for field names and data in Datasheet view. Read/write Boolean.

expression .DatasheetFontItalic

expression A variable that represents a Form object.

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.

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 by using the CreateProperty method and append it to the DAO Properties collection.

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

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
Show:
© 2016 Microsoft