Controlling Who's On Top

  • Thread starter Thread starter Gary Schuldt
  • Start date Start date
G

Gary Schuldt

I have forms A, B, C, & D all open (and opened in that order).

When I close D, I want A to end up on the top (be the active form).

How do I do it?

Thanks.

Gary
 
In the Close event handler for Form D, put in the code
Forms!A.SetFocus

Hope This Helps
Gerald Stanley MCSD
 
Thanks, Gerald,

Does it matter whether I do Me.Close before Forms!A.SetFocus?

I guess I don't know how closing a form affects its own private module code.

Gary
 
Gary

The statements Me.Close and Forms!A.SetFocus do not go
together.

By putting the code Forms!A.SetFocus in the form's Close
event handler, it will get invoked by the Me.Close
statement (wherever it may be in the code) or by the user
clicking on the Close Button, if your form has one.

Hope This Helps
Gerald Stanley MCSD
 
(snip)
Does it matter whether I do Me.Close before Forms!A.SetFocus?

I guess I don't know how closing a form affects its own private module
code.

The code keeps running until it hits a natural end.

For example, say btn_Click calls mysub1 which calls mysub2 which does a
Me.Close. The subsequent code in mysub2 certainly runs, and I think (but
have not checked) that the subsequence code in mysub1, then btn_Click, also
runs.

HTH,
TC
 
TC,

The "natural end" does make sense. I guess I need a better definition of
what "Close X" really does, since it doesn't appear to "terminate" the code
internal to X.

Access Help says, on the one hand, "The Unload event occurs AFTER a form is
closed but before it's removed from the screen."

On the same page, it also says, "When you close a form, the following events
occur in this order:
Unload Þ Deactivate Þ Close
The Unload event occurs BEFORE the Close event." [caps mine]

I didn't find anything on the private module code.

Gary
 
Back
Top