By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,475 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,475 IT Pros & Developers. It's quick & easy.

Resize subform to fit Detail Section

P: 9
Hi There,

Im having a bit of a problem tryin to get my subform to automatically stretch to the size of the detail section when the main form changes size.
I have set the autoresize on both the main and subforms along with the can grow/shrink settings.

I also tried some code which almost worked on the onload event on the main form.

Me.frm_subAssetEdit.Height = Me.Section(0).Height

This would resize the subform to the original height of the detail section when first opened however on resize no change would take place even with a .Refresh call.

Anyhelp is greatly appreaciated.

Mike
Mar 2 '07 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,315
The size of the main form will never change unless you do it through code. If you are doing this through code then you'll want to put the subform resize code in the same place.

If you're talking about maximizing the window and resizing the window by using the mouse, this does not increase the size of the form, this only increases the size of the window. The size of the form remains the same regardless of the size of the window.
Mar 2 '07 #2

MSeda
Expert 100+
P: 159
you need to put the code in the form resize event.
Mar 3 '07 #3

P: 9
>If you're talking about maximizing the window and resizing the window by
>using the mouse, this does not increase the size of the form, this only
>increases the size of the window. The size of the form remains the same
>regardless of the size of the window.

Yes this is what im refering too.

What is happening is that when i open the main form on computers with different resolutions the subform which takes up the entire space of my details section changes size. Whent he details sections changes size and becomes smaller the scroll bar on the side is then partly hidden and only the top arrow and half of the bar can be seen making it hard to scroll down the list of records in the subform.
Mar 5 '07 #4

Rabbit
Expert Mod 10K+
P: 12,315
The easiest solution is to develop on the lowest resolution that it will be used on.
Mar 5 '07 #5

MSeda
Expert 100+
P: 159
If you need to adjust for different screen sizes and resolution you can reference WindowWidth and WindowHeight.

This is just a sample of some code to format a form containing a tab control and some images. It takes a little trail and error to get the proportions right. But as you can see the code is very simple.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. Dim img As Object
  3.  
  4. DoCmd.Maximize
  5. Me.Form.Width = Me.WindowWidth
  6. Me.Label9.Left = (Me.Form.Width - Me.Label9.Width) / 2    'center the label
  7. Me.Label10.Left = (Me.Form.Width - Me.Label10.Width) / 2    'center the label
  8. Me.TabCtl15.Width = Me.Form.Width * 0.98
  9. Me.Detail.Height = Me.WindowHeight * 0.86
  10. Me.TabCtl15.Height = Me.Detail.Height * 0.98
  11. For Each img In Me.Controls
  12. If TypeOf img Is Image Then
  13. img.Width = Me.TabCtl15.Width * 0.975
  14. img.Height = Me.TabCtl15.Height * 0.925
  15. End If
  16. Next
  17.  
  18. End Sub
the resize event I mentioned would be used to reformat the form if the user resizes it after opening it either by dragging the borders or using the control box.
Mar 6 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.