Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 5, 1997

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 that called 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 can remember 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 BAS file):
 
Sub ShowForm(frmFormToShow As Form, _
        frmFrom As Form)
        frmFrom.Hide
        frmFormToShow.Show
        Set frmFormToShow.Callingform = _
                frmFrom
End 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.Show
End Sub
Use this procedure for all child forms except when you need to make the call from the main MDI form. In this case, use this call:
 
ShowChild frmChild

frmChild 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 = frmMain
End Sub
It's a good idea to call procedures to do these tasks because you might want to put extra processing in these procedures. Note you should have error-handing routines as well in the procedures.
Sergio Walter
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date