Open/Close Cmd Button

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi

I have a command button that opens another form. How can
I have the same button close the exsisting form as well?

Thank you
 
Hi Mike! :-)

Mike said:
Hi

I have a command button that opens another form. How can
I have the same button close the exsisting form as well?

I use the Open and Close Macros to open and close forms with the same
button. I first use the Open Macro, selecting Form, then the name of the
form to open, then the Close Macro, and select the form form to close Thus,
when you click the button, the new form opens and the old form then closes
immediately, giving a smooth transistion between forms, reports or whatever.
I use them for my "Exit" navigation tabs as well, which enables the users to
navigate quickly around the database, and without having a lot of things
open at the same time.

You can also use the written code behind the button to do this (which I also
so at times), and others may have a better way of doing it. But, it has
worked very successfully for me for some time. It's clean, fast and
eliminates confusion for the users.

Hope this helps.

Jan :)
 
In the code behind your button that open the form modify the code supplied
by the wizard slightly

1. Collect anything you need from the old form ( in my case 'txtprojectid'
which is used in the form criteria If you don't have an opening criteria
for your new form you don't need that)

2. Close the old form

3. Open the new form ( in my case with a criteria option)



Private Sub cmdOpenForm_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim strProjectID as string

strProjectID = me.txtProjectID

stLinkCriteria = "[ProjectID]='" & strProjectID & "' "
stDocName = "NewForm"

DoCmd.Close

DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
Back
Top