opening one form closes another

Tallica

Registered User.
Local time
Today, 03:59
Joined
Jul 27, 2010
Messages
26
I have a master form.

I have some code which copies the master form to a unique name and opens it. I do this becuase I want to have the form open more then once with different records loaded.

Here is the code

On Error Resume Next
'Delete the form in case it already exists
DoCmd.DeleteObject acForm, Me.t_num

'Make the new form
DoCmd.CopyObject , (Me.t_num), acForm, "Target_Stores_MRRS"

'Open the new form
DoCmd.OpenForm Me.t_num, acNormal

Here is what is happening.

The first time I run it it copies the master form to the new form named to the value of Me.t_num and then opens it.

when the code runs again with a different value for Me.t_num, it closes the first form opened and then opens the new form. The first form still exists. Why is it closing?
 
I have read these articles and that is not what I wnat to do. That is whay I am making a copy of the main form and then opening the copy. I am just curious why the other copies close when nothing told them to.
 
Just wondering if you have any code that is supposed to close any of the forms (apart from the close button)?
 
I do not. I do have a subform that is loading. I am not making a copy of it first. I wonder if that is it.
 
The subform wouldn't affect it because it's just a control pointing to a form.

It may be that it doesn't like being copied from itself so call the code from another form, completely independent from the form to be copied and use a recordset to get the name of the form.
 

Users who are viewing this thread

Back
Top Bottom