Controling form sizes (1 Viewer)

ghudson

Registered User.
Local time
Today, 18:10
Joined
Jun 8, 2002
Messages
6,195
And that could not be any easier using the InsideHeight & InsideWidth commands...

Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
    
    'just for testing
    MsgBox "InsideHeight = " & InsideHeight & vbCrLf & vbLf & "InsideWidth = " & InsideWidth
    
    InsideHeight = 5450 'twips is the unit of measurement
    InsideWidth = 7870
    
Exit_Form_Open:
    Exit Sub
    
Err_Form_Open:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Form_Open
    
End Sub
 

supercharge

Registered User.
Local time
Today, 15:10
Joined
Jun 10, 2005
Messages
215
ghudson said:
And that could not be any easier using the InsideHeight & InsideWidth commands...

No, ghudson, that will not work either. I tried it by maximize the database window first, then double clicked on the form to open it and no matter what sizes you set, it'll be maximized anyway.
 

ghudson

Registered User.
Local time
Today, 18:10
Joined
Jun 8, 2002
Messages
6,195
All you have to do is add the DoCmd.Restore command to the end of the code. I just tested this and it does reset the form size. You have to close and save the changes to all forms involved with the process.

Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
    
    'just for testing
    MsgBox "InsideHeight = " & InsideHeight & vbCrLf & vbLf & "InsideWidth = " & InsideWidth
    
    InsideHeight = 5450 'twips is the unit of measurement
    InsideWidth = 7870
    [COLOR=Blue]DoCmd.Restore[/COLOR]
    
Exit_Form_Open:
    Exit Sub
    
Err_Form_Open:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Form_Open
    
End Sub
 

NewfieSarah

Registered User.
Local time
Today, 19:40
Joined
Feb 11, 2005
Messages
193
supercharge has hit it on the nail, with exactaly what I need. Thanks for all the help ghudson.
 

darylm

New member
Local time
Today, 23:10
Joined
Mar 11, 2008
Messages
1
I used the code ghudson suggested with the DoCmd.Restore line in it, and it works for me (the message box feature is really useful by the way). I'm opening my forms from a switchboard however - not sure if that makes a difference. There was a small "side effect"; when the code resizes my form, it also "unmaximizes" my switchboard in the back ground. The best I could come up with in answer to this was to run a maximize macro on the close event of the form.
 

sonofben

New member
Local time
Today, 15:10
Joined
Dec 10, 2009
Messages
1
I am using ghudson's code and it works like a charm. It is possibly the event procedure you plunk the code into which is causing grief. I tried the form's Activate event, and now the form stays the way I want it to. thanks ghudson!
 

pervezjee

New member
Local time
Tomorrow, 02:10
Joined
May 21, 2017
Messages
3
Searching the forum is a great way to discover and learn the answers to your Access programming questions.

Here is how I set [force] the size of my forms...
Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
    
    'just for testing
    MsgBox "InsideHeight = " & InsideHeight & vbCrLf & vbLf & "InsideWidth = " & InsideWidth
    
    InsideHeight = 5450 'twips is the unit of measurement
    InsideWidth = 7870
    
Exit_Form_Open:
    Exit Sub
    
Err_Form_Open:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Form_Open
    
End Sub
Thanks but it does not work with me
 

Users who are viewing this thread

Top Bottom