Maximize with maximizing
Hi All,
I was having a look around for some code about heights/widths of forms in Access and came across this thread. Just thought I might share this with you all.
I found this bit of code a while back now on the mvps.org/access site. Kudos to the author, Nicole Calinoiu for writing this!
This class module will allow you to resize a 'Main' form to the internal size of the Access client window. This will then allow you to see your 'Main' form in what looks like maximized view (but really not), plus allow you to open up other forms over the top in restored view (normal view).
Create a new class module called clFormWindow and paste the class module into Access which can be found here:
www.mvps.org/access/forms/frm0042.htm
Then, put this constant into your form in the general declarations:
Const SMALL_OFFSET = 5
...and add this procedure into the form too:
Sub ResizeMainForm()
'Resizes this form based on the parent size
Dim aForm As New clFormWindow
With aForm
.hwnd = Forms("frmMain").hwnd
If (.Parent.Width - SMALL_OFFSET) <> .Width Or (.Parent.Height - SMALL_OFFSET) <> .Height Then
.Width = .Parent.Width - SMALL_OFFSET
.Height = .Parent.Height - SMALL_OFFSET
.pLeft = 0
.Top = 0
End If
End With
Set aForm = Nothing
End Sub
It just a matter of calling the above procedure and it will resize the form. I ended up calling this at regular intervals using a timer so that if the user resizes the Access client window, then the main form also resizes.
Hope this helps!
