Navigation

  • Thread starter Thread starter Fie
  • Start date Start date
F

Fie

Right when i open up a new form, how can get it to close the form i
have just navigated away from?

fie
 
Consider the OnLostFocus or OnDeactivate events on the form you have left.
 
When you leave a form several events occur in particular for your purposes
the OnLostFocus and OnDeactivate.

You could add code to either of these events in the relevant event procedure
to close the form.

If you are not experienced in VBA the following code snippet may give you an
idea.

Private Sub Form_Deactivate()

Me.Visible = False

End Sub

or

Private Sub Form_LostFocus()

Me.Visible = False

End Sub

Each of these events will hide the form you have just left, it does not
actually close it. If you want to close it you will have to process the
closure on the forms that will be moving to.

Opening the form you have hidden will merely unhide it and it can give a
snappier appearance to your application so long as the form in question is
not a resource hog, in which case it may be better to close it once you open
another form.
 
Back
Top