您可以使用DatasheetFontHeight属性指定用于在数据表视图中显示和打印字段名称和数据的字体点大小。读/写整数。
备注
此属性仅在Microsoft Access数据库中可用。
对于DatasheetFontHeight属性,可以指定字体大小必须是有效的由指定的字体DatasheetFontName财产。例如,MS Sans Serif仅适用于8,10,12,14,18和24点。
下表包含在 使用格式化(数据表)工具栏设置DAO 属性集合之前不存在的属性,或者可以使用CreateProperty 方法将它们添加到Access数据库(.mdb)中,然后附加它到DAO属性集合。
DatasheetFontItalic * | DatasheetForeColor * |
DatasheetFontHeight * | DatasheetBackColor |
DatasheetFontName * | DatasheetGridlinesColor |
DatasheetFontUnderline * | DatasheetGridlinesBehavior |
DatasheetFontWeight * | DatasheetCellsEffect |
注意 |
---|
当您添加或设置使用星号列出的任何属性时,Microsoft Access会自动将列出的带有星号的所有属性添加到数据库的“ 属性”集合。 |
例
以下示例将Products表的数据表视图中的字体设置为MS Serif,将字体大小设置为10磅,将字体重量设置为medium(500)。
Sub SetDatasheetFont Dim dbs As Object, objProducts As Object Set dbs = CurrentDb Const DB_Text As Long = 10 Const DB_Integer As Long = 3 Set objProducts = dbs!Products SetTableProperty objProducts, "DatasheetFontName", DB_Text, "MS Serif" SetTableProperty objProducts, "DatasheetFontHeight", DB_Integer, 10 SetTableProperty objProducts, "DatasheetFontWeight", DB_Integer, 500 End Sub 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
下一个示例与打开的Products表的数据表视图中的上述示例进行相同的更改。
Forms!Products.DatasheetFontName = "MS Serif" Forms!Products.DatasheetFontHeight = 10 Forms!Products.DatasheetFontWeight = 500