Thread: Form Size
View Single Post
  #2  
Old February 12th, 2009, 07:32 PM posted to microsoft.public.access.forms
Dale Fye
external usenet poster
 
Posts: 2,651
Default Form Size

I have a function I use for this purpose. I got tired of trying to figure
out the size of the form, so this way, I just define the size of the form in
the forms Open event. If you put the three functions below into a code
module, you can call them from any form during it's open event.

Private Sub Form_Open

SizeForm 4, 4

End sub

The subroutine accepts the forms dimensions in inches, and then checks to
make sure that the form dimensions don't exceed certain values. For me and
my users, 9 x 12 is about the max they can view on their monitors. This
function calls two other functions fnTwips(), which simply converts inches to
twips by multiplying by 1440, and fnMin( ), which returns the minimum value
from an array of values being passed to it.

Public Sub SizeForm(HeightInInches As Single, _
WidthInInches As Single, _
Optional frm as Form)

If HeightInInches 9 Then
MsgBox "Height (" & HeightInInches & ") exceeds 9 inches!"
End If
If WidthInInches 12 Then
MsgBox "Width (" & WidthInInches & ") exceeds 12 inches!"
End If

'if the frm object was not passed, assume it is the last form opened
if frm is nothing then Set frm = Forms(Forms.Count() - 1)

frm.InsideHeight = fnTwips(fnMin(HeightInInches, 9))
frm.InsideWidth = fnTwips(fnMin(WidthInInches, 12))

'If the form has somehow been maximized or minimized, this will
'restore it to it's defined size
DoCmd.Restore

End Sub

Public Function fnTwips(Inches As Double) As Integer

fnTwips = Inches * 1440

End Function

Public Function fnMin(ParamArray SomeValues() As Variant) As Variant

Dim intLoop As Integer
Dim myMin As Variant

myMin = Null
For intLoop = LBound(SomeValues()) To UBound(SomeValues())

If IsNull(myMin) And Not IsNull(SomeValues(intLoop)) Then
myMin = SomeValues(intLoop)
ElseIf myMin SomeValues(intLoop) Then
myMin = SomeValues(intLoop)
End If

Next

fnMin = myMin

End Function


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"CGo" wrote:

I'm still new to 2007 and I can't figure out how to size a form other than
fit to window. I'm sure it's something simple that I'm overlooking but any
help would be greatly appreciated.