在DataSheet视图中以拆分形式设置列宽 [英] Set Column Width in DataSheet View in Split Form
问题描述
我有一个Access数据库和一个简单的变更记录表.
Hi I have an Access Database and a simple Change Record Table.
我还有一个窗体,其中所有字段都显示在屏幕的上半部分,而数据表视图则在底部.见下文.
I also have a Form where I have got all the fields in the top half of the screen and a Datasheet View in the Bottom. See below.
我正在尝试将列宽设置为均匀分布在屏幕的整个宽度上,但到目前为止没有成功.
I am trying to set the column widths evenly distributed across the entire width of the screen but so far been unsuccessful.
我的代码如下:
Private Sub Form_Load()
Dim currentFormWidth As Integer
currentFormWidth = Me.Width
MsgBox ("Current width of my form is : " & currentFormWidth)
Dim standardColumnWidth As Integer
standardColumnWidth = currentFormWidth / 13 ' Columns of Data to display
Me.Target_Date.ColumnWidth = standardColumnWidth
Me.Change_Type.ColumnWidth = standardColumnWidth
Me.FullName.ColumnWidth = standardColumnWidth
Me.CDSID.ColumnWidth = standardColumnWidth
Me.Grade.ColumnWidth = standardColumnWidth
etc...
End Sub
列宽保持不变.我希望在数据表视图中看到所有列,从let到右边都适合. 我认为我没有使用正确的语法. 我认为应该是以下内容: FormName.SubFormName.Target_Date.ColumnWidth = standardColumnWidth ???
The column widths remain unaltered. I would expect to see columns all fit from let to right within the Datasheet View. I think I am not accessing in the right syntax. I think it shold be something like the following : FormName.SubFormName.Target_Date.ColumnWidth = standardColumnWidth ???
任何指导将不胜感激.提前致谢.
Any guidance would be appreciated. Thanks in advance.
推荐答案
我认为您的做法正确.要从主窗体引用子窗体,您需要这样做:
I think your on the right track. To refer to a subform from the mainform you need to do it like this:
Me.subFormControlName.Form.Target_Date.ColumnWidth = standardColumnWidth
请注意使用控件名而不是子窗体的表单名!
Be aware to use the controlname not the formname of the subform!
在此处查看我的答案:从查询
See my answer here: Referring to a Subform from a Query
这篇关于在DataSheet视图中以拆分形式设置列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!