访问 - 使用父表单上的按钮使子表单字段不可见:)
我有一个带有父表单的访问数据库,该父表单在数据表视图中有一个子表单。子表单具有不需要始终可见的高级字段,让我们使用子表单“deliverylines”中的一个字段“productcode”,父表单是“deliveryheaders”。所以我需要一个按钮作为主窗体,使“产品代码”列可见。
这就是我一直在尝试的,但它只是向我抛出错误:(
Private Sub showadvanced_Click()
Me.DeliveryLines.Productcode.Visible = True
end sub
I have an access database with a parent form which has a subform in datasheet view. The subform has advanced fields that don't need to be visible all the time, lets go with one field "productcode" in subform "deliverylines", parent form is "deliveryheaders". So i need a button the main form that will make the "productcode" column visible.
This is what I've been trying but its just throwing errors at me :(
Private Sub showadvanced_Click()
Me.DeliveryLines.Productcode.Visible = True
end sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了隐藏数据表视图中的列,您需要使用如下代码:
Forms(Me.Name)("deliverylines").Form.Controls("productcode").ColumnHidden = True
这将设置列隐藏属性
请注意,引用子表单上的控件的完整语法如下:
我提供的示例代码假定您的子表单控件名称是deliverylines
In order to hide a column in datasheet view you would need to use code like the following:
Forms(Me.Name)("deliverylines").Form.Controls("productcode").ColumnHidden = True
This will set the column hidden property
Note the full syntax to refer to a control on a subform is as follows:
The example code I have supplied presumes that your subform control name is deliverylines
对于数据表,您需要将列宽设置为零: http://msdn.microsoft.com/en-us/library/aa224081(v=office.11).aspx
For a datasheet, you will need to set the column width to zero: http://msdn.microsoft.com/en-us/library/aa224081(v=office.11).aspx