Access () 的 Form.DatasheetBackColor 屬性
使用Visual Basic中的DatasheetBackColor屬性,在 Microsoft Access 資料庫內的資料工作表檢視中指定或決定整個資料表、查詢或表單的背景色彩。 讀取/寫入的 Long。
語法
運算式。DatasheetBackColor
expression 代表 Form 物件的變數。
註解
下列設定資訊適用于 Microsoft Access 資料庫和 Access 專案 (.adp) 。
設定資料表或查詢的 DatasheetBackColor 屬性將不會影響使用資料表或查詢當做為資料來源為表單的此屬性設定值。
下表包含 DAO Properties 集合中不存在的屬性,直到您使用 [格式化] (資料工作表) 工具列加以設定,或者您可以使用 CreateProperty 方法將它們加入 Access 資料庫中,並將它附加至 DAO Properties 集合。
注意事項
當您使用星號新增或設定任何屬性時,Access 會自動將它新增至 Properties 集合。
範例
下列範例會使用 SetTableProperty 程式,將資料表的字型色彩設定為深藍色,並將其背景色彩設定為淺灰色。 如果 「 找不到屬性"會發生錯誤時的屬性設定, CreateProperty 方法用來將屬性新增至該物件的 Properties 集合。
Dim dbs As Object, objProducts As Object
Const lngForeColor As Long = 8388608 ' Dark blue.
Const lngBackColor As Long = 12632256 ' Light gray.
Const DB_Long As Long = 4
Set dbs = CurrentDb
Set objProducts = dbs!Products
SetTableProperty objProducts, "DatasheetBackColor", DB_Long, lngBackColor
SetTableProperty objProducts, "DatasheetForeColor", DB_Long, lngForeColor
Sub SetTableProperty(objTableObj As Object, strPropertyName As String, _
intPropertyType As Integer, varPropertyValue As Variant)
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
' Error is unknown.
MsgBox "Couldn't set property '" & strPropertyName _
& "' on table '" & tdfTableObj.Name & "'", vbExclamation, Err.Description
Err.Clear
Else
' Error is "Property not found", so add it to collection.
Set prpProperty = objTableObj.CreateProperty(strPropertyName, _
intPropertyType, varPropertyValue)
objTableObj.Properties.Append prpProperty
Err.Clear
End If
End If
objTableObj.Properties.Refresh
End Sub
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。