Solved

Programmatically resize subform datagrid display

Posted on 2004-10-14
2
430 Views
Last Modified: 2008-02-01
I need a way to programmatically adjust the size of the columns in a subform so the scrollbar goes away.

Something akin to double-clicking the column seperators to force them to the size of the header.

Here is a picture depicting what I want to accomplish:

http://www.robotzgame.com/junk/subform_resize.gif

Thanks,

Tom
0
Comment
Question by:knowlton
2 Comments
 
LVL 11

Accepted Solution

by:
Jokra_the_Barbarian earned 500 total points
ID: 12309144
Try this:

Dim ctl  As Control
   
        For Each ctl In Me.subform1.Form.Controls
               If ctl.ControlType = acTextBox And ctl.Properties("visible") = True Then ' Only set the width for visible textboxes
                    ctl.SetFocus
                    SendKeys "%B", False
                    DoCmd.RunCommand (acCmdColumnWidth)
                End If
        Next ctl
0
 
LVL 5

Author Comment

by:knowlton
ID: 12309334
Or how about this?

Private Sub ResizeCommentsSubForm()
    Forms![frmEntriesForm]![frmCommentsSUB]![TimeStamp].ColumnWidth = -1
    Forms![frmEntriesForm]![frmCommentsSUB]![CommentType].ColumnWidth = -1
    Forms![frmEntriesForm]![frmCommentsSUB]![Comment].ColumnWidth = 4000   'twips
End Sub

(I found my old code for handling this)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now