Applecore Pages on Microsoft Access

Opening one Form and closing the previous Form

If you wish to have only one form in your database open at the time, then you can use the OpenArgs argument of the OpenForm method to pass the name of the current form, and then when the next form has opened, check if there is a value, and close the form.

Place the following code in the form that is used to open the next form:

Private Sub cmdOpenfrm2_Click()
    DoCmd.OpenForm "frm2", , , , , , Me.Name
End Sub

And then in the OnLoad event for the second form:

Private Sub Form_Load()
    If Not IsNull(Me.OpenArgs) Then DoCmd.Close acForm, Me.OpenArgs
End Sub

Using this method allows you to open the same form from different forms in your database, and of course, since you have the name of the previous form, stored as a variable in OpenArgs, then you are able to return to that form quite easily.

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 14:54:06