Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Developers    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Dynamic sizing subform
Brian Crawford 
    
3 years ago
I have a subform that I use in Datasheet view to review and edit records in a table that match user search criteria.  The main form also has a button to allow the user to add and remove columns and change their column orders. I do this by changing the .Visible and .ColumnOrder properties on the controls within the data sheet subform.

My issue is that as I add more columns into the view, they exceed the initial width of the subform and require scrolling around inside the subform on the main form.

I would like to have a way to dynamically adjust the width of the subform (and if needed, the main form too) to fit the visible controls so that the user doesn't need scroll bars to view the columns that don't fit into the static sized subform.  I would also like to set a minimum and maximum width for the forms (mostly for cosmetic purposes).

I was inspired by the Access Developer 37 lesson, but that pertains to adjusting the size of a control and not the forms themselves.
Kevin Yip  @Reply  
     
3 years ago
One way is to let the user manually resize the main form by dragging the corners, and have the subform auto-resize, as shown in the picture below.  That would only require coding main form's Resize event.  For instance:

Private Sub Form_Resize()
    With Me!MySubform
        .Width = Me.InsideWidth - 750
        .Height = Me.InsideHeight - 2520
    End With
    Me!Textbox1.Top = Me.InsideHeight - 1000
    Me!Label1.Top = Me.InsideHeight - 1000
End Sub

My code above also auto-moves the textbox and its label that are below the subform.  "750" and "2520" are the sizes of the right and bottom margins the subform should have.  They are in "twips" (twentieth of an inch point), which is actually one-1440th of an inch.  So, 750 twips = 750 / 1440 = about half an inch.
Kevin Yip  @Reply  
     
3 years ago

Brian Crawford OP  @Reply  
    
3 years ago
Thank you

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developers.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/8/2026 12:42:51 AM. PLT: 0s