Determining wether a form is maximised minimised or restored

  • Thread starter Thread starter jag
  • Start date Start date
J

jag

Is it possible to detect when a form is maximised or restored? Does
anybody know how to detect when a form is
maximised or restored?

I have tried using the isZoomed function on my form activate

i.e

Sub Form_Activate()
Dim intWindowHandle As Long
intWindowHandle = Screen.ActiveForm.hWnd
If Not IsZoomed(intWindowHandle) Then
DoCmd.Maximize
End If
End Sub

but I get an error saying that an active window has to be opened.
any ideas?

Thanks
Dee
 
Possibly, because your Form is not "officially" the ActiveForm on screen
yet.

Why bother checking whether it is zoomed or not? Simply use:

DoCmd.Maximize

If the Form is already maximized, Access will ignore your statement. If it
is not maximized, Access will maximize it as you want!
 
I actually want the form to be in the restored state not maximised or
minimised,
sorry I know the code isn't quite right I copied the wrong example. Is there
a way to
determine this?

thanks again

dee
 
Just use:

DoCmd.Restore

If the Form is being opened restored, it will stay restored. If it is being
opened as maximised or minimised. the DoCmd.Restore will change it to
restored state.
 
Back
Top