How to set a form width in code

Gkirkup

Registered User.
Local time
Yesterday, 16:55
Joined
Mar 6, 2007
Messages
628
I have a form which is called in several modes, some of which need a wider or narrower form. How do I set the form width?
I have tried me.width = 9.5. That did nothing.
I also tried Me.detail.width = 9.5. That gave an error message.
Is it possible to set the width of the form?

Robert
 
Hi,
You may need some code like this to work it out:

Private Sub Form_Open(Cancel As Integer)

Const conInchesToTwips = 1440

Dim intRight As Integer
Dim intDown As Integer
Dim intWidth As Integer
Dim intHeight As Integer
Dim intMyInt As Integer

DoCmd.Restore

intMyInt = Me.Width / 4220 ' you can change it to your need.

intRight = (intMyInt * conInchesToTwips)
intDown = 0
intWidth = (intMyInt * conInchesToTwips)
intHeight = (intMyInt * conInchesToTwips)

DoCmd.MoveSize intRight, intDown, intWidth, intHeight

End Sub
 

Users who are viewing this thread

Back
Top Bottom