Determining wether a form is maximised minimised or restored

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
 
V

Van T. Dinh

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!
 
J

jag

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
 
V

Van T. Dinh

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top