trying to set form size

qwertyjjj

Registered User.
Local time
Today, 04:40
Joined
Aug 8, 2006
Messages
262
I am trying to set the form size through VBA code when the form loads.
I have autoresize set to No and then run this:
DoCmd.MoveSize 100, 100, 100, 100

...except nothing seems to happen. The form is still maximised.

Any ideas?
 
you can't resize a maximized form...maximized means to literally take up the access window. Execute a restore command first, then resize
 
You will need to use:

Code:
With Me
    .InsideHeight = 2200
    .InsideWidth = 2200
End With

Remember that for coding you use twips
 
Well...partially better...but

The restore command works, except neither the MoveSize or .InnerHeight mentioned above do anything.
The form stays at its absolute minimum size (which is just the title bar and the close button).

Any ideas on what to try here?
Not only that, all the other forms lose their maximum setting as soon as I run the restore on this form's load event.
 
When you use Restore it does make all objects lose maximization. When you say
except neither the MoveSize or .InnerHeight mentioned above do anything.
The form stays at its absolute minimum size (which is just the title bar and the close button).
What value did you use for the InnerHeight value? Remember that twips are 1440 to an inch, so if you only use 1440, then the form will be 1 inch in height or the minimum size that your form will display. If you want it to be 8 inches high, then you have to use 11520. Also, on what event did you try to use it?

If you have set something to maximize in the database, all objects will maximize. I think you need to do what I do and set the code for each form and report to either maximize (or set size as shown) on load and then set Restore when closed. And, I usually will set the startup property of the database window to not show so that way it doesn't become a factor.
 
[Forms]![frmName].Move _
Left:=0, Top:=0, Width:=6800, Height:=4000
 
Well...
I reset and used higher figures (twips)...so that was fine. Thanks.

I'm not sure what is causing the parent form to become unmaximised though?
When the form loads, I have an onLoad event:
DoCmd.Maximize

The user clicks a button to show another form. In the onLoad of that form I have:
DoCmd.Restore
Form.RecordSource = Me.OpenArgs
Forms.Top10Debtors.Move , , 12000, 5000

At which point, the parent form becomes unmaximised.
Is it something to do with the DoCmd.Restore ?
 
DoCmd.Maximise will maximise all of your open forms.
DoCmd.Restore will restore all of your open forms to their original size.

Hope this helps.
 
Okay, so that's what is causing the problem.
Is it possible to just restore 1 form?

I've tried Forms.[Forname].Restore but that errored.
 
boblarson said:
Remember that twips are 1440 to an inch

Bob,

I have been doing a bit of form & control sizing over the last few days and was wondering about twips.

I have a failry large monitor and reasonable eyesight (when I bother to wear my glasses). The moitor resolution is set to maximun with large icons.

My problem is that the first version of my DB was unreadable on my managers PC as he has a smaller monitor (17" to my 19") and is near blind so has the resolution set at 680x760 or whatever the lowest setting in Wndows xp is. Most of theforms was

Beacuse of this, I resized all forms to suit his display. Since then, as noted, I have been using twips to size objects and wondered how they could give a standard dimension when it must surely be a different size on the screen resolution? :confused:

Somneof my users have the 19" monitor set at max resolution and small icons and the forms are squished to the point that I am struggling to read them.

I'd be interested on any insight to the 'twip' and screen resolution.

Pre-Post edit:
Just found this as the first hit on a Google search:

Twip


Unit of measurement, One TWentIeth of a Point, ie 1/20 of a printer's point. There are thus 1,440 Twips to an inch or about 567 Twips to a centimetre. This unit of measurement seems only to have seen use in Billyware formats and products- notably Rich Text Format, Visual Basic, and Visual C++.

And from Wikipedia:

Twip
From Wikipedia, the free encyclopedia
Jump to: navigation, search
A twip (or TWIP, which stands for Twentieth of a Point) is a typographical measurement. It is also used as the default measurement in Visual Basic 6 and prior where in windows "Small fonts" mode, 15 twips is equal to 1 pixel. A twip is 1/1440 of an inch when derived from the PostScript point at 72 to the inch, as opposed to the printer's point at 72.27 to the inch. It is also a commonly used unit within Symbian OS bitmap images

Am I missing something or is there some sort of standard resolution that these things are calculated for?
 
Keith:

I'm not overly familiar with what would constitute what, if any, resolution constant a twip would be measured in. It may be that it varies due to resolution or it may not. However, I know that there are some posts (somewhere in this forum) that dealt with modifying things based on screen resolution - so resizing forms based on resolution of the screen viewing it. It's a bit complex and I never needed to use it, but I know something is out there that might help.

Good luck with it all.
 
you can easily move between twips and inches, but pixels per inch is a logarithmic function of the actual display resolution. In order to do the conversion, you will need to retrieve the current system resolution settings and do the mathematical conversion to twips (which will be different for both horizontal and vertical). All that said, of course it can be done, It just takes some digging throught the api.;)
 
So, is there any way to have a maximised form and then have another form that sits in the middle of the window but is smaller when a command button is clicked ?

Any ideas on a workaround?
 
Your only recourse will probably be to size the form in design view to fill the whole screen and set Auto Resize = Yes, Auto Center = Yes, Border Style = Dialog or Thin & Remove the Minimize and Maximize buttons.

Hope this helps.
 
You can also specify explicitly what size each form is and there is code somewhere on this forum to resize forms based on screen resolution, but I don't have it memorized as I have never used it.
 
TWIPs verses resolution

Bob,

Thanks for the opinion.

I think that trial and error is the most obvious way to go. I'll test my db on the best and worst case scenarios and tweak until it is viewable on both.

Long time ago I did see something on the forum regarding zooming for different resolutions but I think it was horrendously complicated - not for me at my current skill level, or the likely skillful of the poor souls who will have to maintain this db after I move on. LOL. :)
 
There is another way!

One way I use which allows a main form to remain full size onscreen when another smaller (not-maximized) form is called up, is to make the small form a pop-up form. (See Form Properties/Other). You may or may not want to make it modal as well. Look them up in HELP to see the implications thereof. Good Luck!

-Curt
 
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!
:)
 

Users who are viewing this thread

Back
Top Bottom