Auto Resize of forms??

Wilfy06

Registered User.
Local time
Today, 00:48
Joined
Sep 6, 2006
Messages
15
Hi People,

Whilst at college was positive there was some coding, to automatically re-size the form when opening?? can anyone help with this, have spoken to a few people and they say to change in design view but i am finding this annoying. Any help would be appreciated.

Thanks
 
No, not different screen resolutions, but there was coding to move and size the form so u can work in design view full screen, then when you press Form view it fixes the size, i remember doing this at college, but can't remember the command to do it.
Thanks
 
The following code by Ghudson resizes the form. Add the code to your form and then view your form and position it to where you want on the screen and save. The DoCmd.Restore then remembers the last position.

=======================================================

© Ghudson

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open

'Added by Allan L Taylor
DoCmd.Restore

'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

========================================================


The following code resizes and moves the whole access window, design your forms to fill the area you selected.

Usage: add to form on load event add:- SizeAccess 130, 40, 600, 800

'note first two parameters are screen position, last two are size


Create a module and add the following.


'====================================
' Global Declarations
'====================================

Option Compare Database
Option Explicit

'NOTE: The following "Declare" statement is case sensitive.

Declare Sub SetWindowPos Lib "User32" (ByVal hWnd&, _
ByVal hWndInsertAfter&, _
ByVal X&, ByVal Y&, ByVal cX&, _
ByVal cY&, ByVal wFlags&)

'Moves MS Access window to top of Z-order.
Global Const HWND_TOP = 0

'Values for wFlags.
Global Const SWP_NOZORDER = &H4 'Ignores the hWndInsertAfter.

Function SizeAccess(cX As Long, cY As Long, _
cHeight As Long, cWidth As Long)

Dim h As Long
'Get handle to Microsoft Access.
h = Application.hWndAccessApp

'Position Microsoft Access.
SetWindowPos h, HWND_TOP, cX, cY, cWidth, _
cHeight, SWP_NOZORDER

End Function
 
Thanks Allan & Ghudson, thats worked a treat a lot of people said thats its not possible or you can't do it!! will have to go and ask permission to look smug for rest of the day!! Ha thanks again
 
Just thought another quick question, i am aware that in Excel it is possible to hide actions of the macro was wondering if the same could be done in access? just so my now fully automatic form re-sizes in privacy and not for the user to see?
Thanks Again
David
 
allan57 said:
check out Application.Echo in vb help
Ensure you have the code to turn the Echo back on in your error handler or else the db will appear to be stuck if the user hits a runtime error while the Echo is turned off. Or vice versa.
 
Thanks Ghudson, did have a couple of problems with it on where to put coding but seems to be doing the job now i used

Echo, True/False, "comment of your choice" is that right????

Looks like its working, but just think i have done it wrong!!
 
try the following method:

Public Function ExampleProcedure()

On Error GoTo ErrorTrap

Application.Echo False

'do something here

Application.Echo True

Exit Function

ErrorTrap:

Application.Echo True

MsgBox Err.Number & " " & Err.Description

End Function
 

Users who are viewing this thread

Back
Top Bottom