Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's up with the OnFocus event of a form?

Status
Not open for further replies.

mike777

Programmer
Jun 3, 2000
387
US
I've read several of the resolutions to restoring a form's size in the forum. The best one for me so far has been the one where it suggests to use "Docmd.Restore" in the OnClose event of a report to restore the state of the windows within Access. That works well.
But what I can't figure out is, what if I want to toggle back and forth between a maximized report and a form that has a special window size? It seems to me that setting the OnFocus event to DoCmd.Restore would work fine. But it's like it doesn't even respond to the OnFocus event. I say that also because I've tried in the past to assign actions to the OnFocus events with the same deadpan results.
Any suggestions?
Thanks!!!
 
OnFocus is a bit screwed up, I'm afraid. What it originally did was fire when the user switched from another app to that form. I think it may also fire for an MDI child, too. But not when the focus is leaving a sibling window. I myself wouldn't depend on it.

Chip H.
 
When you select a form the Activate event fires. You can set the form property "WindowState" to one of the following constants.

vbMinimized
vbMaximized
vbNormal <-- This one restores the window.

You can do something like this:

Me.WindowState = vbNormal

or

frmMain.WindowState = vbMaximized

Snaggs
tribesaddict@swbell.net
If a parsley farmer is sued, can they garnish his wages?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top