Set Column Width in DataSheet View in Split Form

拜拜、爱过 提交于 2019-12-02 07:11:10

问题


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.

My code is as follows :

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

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.


回答1:


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



来源:https://stackoverflow.com/questions/36933449/set-column-width-in-datasheet-view-in-split-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!