Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing all datasheet columns on activate

Status
Not open for further replies.

DRH192

Programmer
Apr 25, 2005
96
GB
Hello all,

A really annoying problem which I have always been to lazy to enquire about before is the resizing of datasheet columns.

Is it possible to have all columns resize so that all contents of a field is displayed? Basicly the same as double clicking the column header.

Cheers
 
Select all columns - (don't select all data via the little square in top left), highlight all the actual columns by clicking the first columns header and holding mouse button whilst moving right.
go to format - column width, select best fit.
 
sorry, i totally mislead you. I should have said that I want to do this via vba when the form loads up.
 
How are ya DRH192 . . .

Try this:
[ol][li]Open the form in [blue]design view[/blue].[/li]
[li]In the [blue]Tag[/blue] property of each textbox that appears in [blue]DataSheet View[/blue], enter a question mark [blue]?[/blue] (no quotations please!)[/li]
[li]In the forms [blue]Load[/blue] event, copy/paste the following:
Code:
[blue]   Dim ctl As Control
   
   For Each ctl In Me.Controls
      If ctl.Tag = "?" Then ctl.ColumnWidth = -2
   Next[/blue]
[/li]
[li]Done![/li][/ol]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Problem solved, very tidy solution that, especially as you can make a multiple selection of all the controls in the subform and enter the tag property collectively.

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top