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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Size Problem When returning from Report Preview

Status
Not open for further replies.

bn2335813

Programmer
Oct 8, 2001
10
IL
I have a Access application based on a one Main Maximized Form and selecting from it subforms to do spesific tasks.
One of the subforms is doing a Report PrintPreview .
When returning from the Report PrintPreview the Main Maximized Form shrunk in size, and I have to always Click Maximize from Windows Menu to restore .
So, there is any way to overcome this problem ?

Thanks in advance !!

 
Put the following VBA code in the OnActiviate Event Procedure of your form. Change the name of the form within the double-quotes if I don't have the form name correct.

DoCmd.SelectObject A_FORM, "Main Maximized Form"
DoCmd.Restore

Good luck. Bob Scriver
 
Should it not be

Docmd.Maximize?

I use this in the On_Open and On_Activate events of all my maximized forms as Access is a great one for restoring forms (i.e. chaning them to non-maximized) when it feels like it. Have fun! :eek:)

Alex Middleton
 
AlexMidd: The suggested code should return the form to their previously min/maximized state depending on what they were before the Print Preview changed the default. This way it should work both ways.

I use it on smaller forms that get maximized during the Print Preview process where I maximize the Print Preview screen. Upon closing the Print Preview screen the focus returns to the form and the code automatically returns it to the small non-maximized size. Bob Scriver
 
Well, not exactly. Restore puts the window into "Restore" mode, i.e. not maximized but still visible. This is different from maximized, i.e. filling the screen, and minimized, i.e. not visible but iconized or shown on the task bar.

The easiest way to ensure forms stay maximized is to use the Maximize command. Have fun! :eek:)

Alex Middleton
 
Thanks to all of you !!! all the tips are great !!

balaban noel
 
Correct me if I'm wrong, but wouldn't it be easier to just put the following code in the On_GotFocus event:

doCmd.Maximize

That way, anytime the window gets the focus, it maximizes. That always works for me.

Will
 
That might work but it is not guaranteed that the form will get the focus each time it is displayed. Putting it in the OnActivate event works every time for me. Have fun! :eek:)

Alex Middleton
 
Hmmm. What exactly is the definition of OnActivate? I've never used that event as a trigger. Could you explain the difference between OnGotFocus and OnActivate?

According to Access Help files, the Activate event occurs whenever a form receives the focus. The main point though does seem that the activate event occurs before the GotFocus event. But I'm assuming that the activate event occurs ONLY when the form receives the focus.

You do make a good point. What if there are two forms in front of the main window and the other form receives the focus in front of the window you want maximized? Would the Activate event occur then? But would you need it to, considering that another form has the focus?

Bah. Too many questions. I guess either way would work. As with you, using the OnGotFocus event works every time for me too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top