ColumnHidden 属性 (权限)ComboBox.ColumnHidden property (Access)
02/20/2019
本文内容
ColumnHidden 属性可用于显示或隐藏数据表视图中的指定的列。You can use the ColumnHidden property to show or hide a specified column in Datasheet view. 读/写 Boolean。Read/write Boolean.
语法Syntax
表达式。ColumnHiddenexpression.ColumnHidden
_表达式_一个代表**ComboBox** 对象的变量。expression A variable that represents a
备注Remarks
例如, 您可能希望隐藏过宽的CustomerAddress字段, 以便可以查看CustomerName和PhoneNumber字段。For example, you might want to hide a CustomerAddress field that's too wide so that you can view the CustomerName and PhoneNumber fields.
[!注释] ColumnHidden 属性应用到数据表视图中的所有字段和窗体控件窗体位于数据表视图中。The ColumnHidden property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.
隐藏与 ColumnHidden 属性在数据表视图中的列将不隐藏窗体视图中的同一列中的字段。Hiding a column with the ColumnHidden property in Datasheet view doesn't hide fields from the same column in Form view. 同样,在窗体视图中控件的 可见 属性设置为 False 不会隐藏数据表视图中的相应列。Similarly, setting a control's Visible property to False in Form view doesn't hide the corresponding column in Datasheet view.
备注
[!注释] 若要设置或更改使用 Visual Basic 的表或查询此属性,必须使用列的 属性 集合。To set or change this property for a table or query by using Visual Basic, you must use a column's Properties collection. 有关使用properties集合的详细信息, 请参阅**properties**。For more information about using the Properties collection, see
即使字段相应的列在表的“数据表”视图中是隐藏的,仍然可以在查询中显示该字段。You can display a field in a query even though the column for the field is hidden in table Datasheet view. 即使应用了筛选后列仍然是隐藏的,照样可以将该隐藏列中的值用作筛选的标准。You can use values from a hidden column as the criteria for a filter even though the column remains hidden after the filter is applied.
字段的 列宽 属性设置为 0,或调整为零宽度在数据表视图中,将导致 Microsoft Access 将相应的 ColumnHidden 属性设置为 True 。Setting a field's ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, causes Microsoft Access to set the corresponding ColumnHidden property to True. 取消隐藏列将 ColumnWidth 属性恢复为之前隐藏了该字段的值。Unhiding a column restores the ColumnWidth property to the value it had before the field was hidden.
[!注释] ColumnHidden 属性不在设计视图中可用。The ColumnHidden property is not available in Design view.
示例Example
下面的示例隐藏 "产品" 窗体的 "数据表" 视图中的 "产品id " 字段。The following example hides the ProductID field in Datasheet view of the Products form.
Forms!Products!ProductID.ColumnHidden = -1
下一个示例隐藏 "产品" 表的 "数据表" 视图中的 "产品id " 字段。The next example hides the ProductID field in Datasheet view of the Products table.
Public Sub SetColumnHidden()
Dim dbs As DAO.Database
Dim fld As DAO.Field
Dim prp As DAO.Property
Const conErrPropertyNotFound = 3270
' Turn off error trapping.
On Error Resume Next
Set dbs = CurrentDb
' Set field property.
Set fld = dbs.TableDefs!Products.Fields!ProductID
fld.Properties("ColumnHidden") = True
' Error may have occurred when value was set.
If Err.Number <> 0 Then
If Err.Number <> conErrPropertyNotFound Then
On Error GoTo 0
MsgBox "Couldn't set property 'ColumnHidden' " & _
"on field '" & fld.Name & "'", vbCritical
Else
On Error GoTo 0
Set prp = fld.CreateProperty("ColumnHidden", dbLong, True)
fld.Properties.Append prp
End If
End If
Set prp = Nothing
Set fld = Nothing
Set dbs = Nothing
End Sub
支持和反馈Support and feedback
有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.