How do I adjust column width programatically in subform

J

Jeff Stroope

Hi,

I have a subform on my main form that is a datasheet view of a query. The
subform has 1 column. When the main form opens, the subform column does not
completely fill the width of the subform control. If I go to the right edge
of the column heading and double click, the column auto fits to the width of
the subform window. Is there any way to do this programatically when the
form opens?
 
U

UpRider

Jeff, I don't know how to permanently stretch the column width, but here's
code to make the columns as wide as necessary for the data it contains. It
also keeps the user from collapsing a column to zero width. This code is for
3 columns.
Documentation *says* columwidth can be set directly in twips, but I couldn't
get that to work.

Private Sub Form_Current()
Me.dueCompDate.ColumnHidden = False
Me.dueDate.ColumnHidden = False
Me.dueTask.ColumnHidden = False
Me.dueCompDate.ColumnWidth = -2
Me.dueDate.ColumnWidth = -2
Me.dueTask.ColumnWidth = -2
End Sub

UpRider
 
J

Jeff Stroope

Thanks!
--
Thanks,

Jeff


UpRider said:
Jeff, I don't know how to permanently stretch the column width, but here's
code to make the columns as wide as necessary for the data it contains. It
also keeps the user from collapsing a column to zero width. This code is for
3 columns.
Documentation *says* columwidth can be set directly in twips, but I couldn't
get that to work.

Private Sub Form_Current()
Me.dueCompDate.ColumnHidden = False
Me.dueDate.ColumnHidden = False
Me.dueTask.ColumnHidden = False
Me.dueCompDate.ColumnWidth = -2
Me.dueDate.ColumnWidth = -2
Me.dueTask.ColumnWidth = -2
End Sub

UpRider
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top