Keep Track of the Last Form

In your MDI application, you might have many child forms and need a form to go back to the form thatcalled it. In each child form, declare this variable:

 Public Callingform As Form

Before calling a form, set CallingForm to the form that is calling it so that the form being called canremember which form called it. Use this call to call a form:

 ShowForm frmNextForm, Me

frmNextForm is the form that you’re calling, and ShowForm is this Global Procedure (declared in a BASfile):

 Sub ShowForm(frmFormToShow As Form, _        frmFrom As Form)        frmFrom.Hide        frmFormToShow.Show        Set frmFormToShow.Callingform = _                frmFromEnd Sub

To close a form and go back to the form that called it, use this call:

 ExitForm Callingform, Me

ExitForm is this global procedure:

 Sub ExitForm(Callingform As Form, _        ThisForm As Form)        Unload ThisForm        Callingform.ShowEnd Sub

Use this procedure for all child forms except when you need to make the call from the main MDI form. Inthis case, use this call:

 ShowChild frmChildfrmChild is the MDIChild form you're calling, and ShowChild is defined in the MDI form:Private Sub ShowChild(frm As Form)        frm.Show        Set frm.Callingform = frmMainEnd Sub

It’s a good idea to call procedures to do these tasks because you might want to put extra processing in theseprocedures. Note you should have error-handing routines as well in the procedures.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: