1

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. enter image description here

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.

Erik A
  • 31,639
  • 12
  • 42
  • 67
mond007
  • 119
  • 1
  • 8
  • 22

1 Answers1

2

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

Community
  • 1
  • 1
BitAccesser
  • 719
  • 4
  • 14
  • Would likely work if there was a subform. But OP says the datasheet is via Split form, not subform. – June7 Oct 07 '18 at 19:11