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 wOOdy-Soft 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!!!
 
From the help (emphasis is mine).

These events occur when the focus moves in response to a user action, such as pressing the TAB key or clicking the object, or when you use the SetFocus method in Visual Basic or the SelectObject, GoToRecord, GoToControl, or GoToPage action in a macro.

MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Remember the activate event in a form will not fire when the form is a subform !

This code works fine for me.
code in the form:
Private Sub Command0_Click()
DoCmd.OpenReport "report1", acViewPreview
Reports!report1.Report_Activate
End Sub
code in the report:
Public Sub Report_Activate()
DoCmd.Maximize
End Sub
Private Sub Report_Close()
DoCmd.Restore
End Sub
Private Sub Report_Deactivate()
DoCmd.Minimize
Forms!form1.SetFocus
DoCmd.Restore
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top