open form on close form

J

Junior

I have a Form1 with a command button that closes the form
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
DoCmd.Close

Then in the Form1 Close event I put this code
Private Sub Form_Close()
On Error GoTo Err_HandleErr_Click
DoCmd.OpenForm "frm2", DataMode:=acFormEdit, WindowMode:=acDialog

frm2 opens on top of Form1 -i.e Form1 doesn't close-
what am i doing wrong?
 
D

Dirk Goldgar

Junior said:
I have a Form1 with a command button that closes the form
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
DoCmd.Close

Then in the Form1 Close event I put this code
Private Sub Form_Close()
On Error GoTo Err_HandleErr_Click
DoCmd.OpenForm "frm2", DataMode:=acFormEdit, WindowMode:=acDialog

frm2 opens on top of Form1 -i.e Form1 doesn't close-
what am i doing wrong?

Since you're opening frm2 in dialog mode, the code in Form1's Close
event cannot finish until frm2 is closed or hidden -- that's what dialog
mode does. And because the Close event can't finish, the form can't
close.

Do you actually need to frm2 in dialog mode? If not, remove the
WindowMode:=acDialog argument from the DoCmd.OpenForm call.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top