Wrong form being closed

Gkirkup

Registered User.
Local time
Today, 03:11
Joined
Mar 6, 2007
Messages
628
I have a main form. A Button on the main form pops up an email form. I send the email and do a Dcmd.Close on the email form. But what happens is the main form closes and the pop-up email form remains open!
I have tried doing a SetFocus to one of the controls on the email form before doing the DoCmd.Close, but still the wrong form closes.
What can I do to make sure that the correct form closes?

Robert
 
Change the code to this:

DoCmd.Close acForm, Me.Name, acSaveNo
 
Bob: Thanks. I am not clear what to put in Me.Name, as I am already on that form. Would that be 'Me.MyFormName' ?

Robert
 
Or if I do this from the main form, how would I code it? The pop up form is a separate form and not a subform.

Robert
 
You don't change it at all. You use specifically, as I have written:

Me.Name

which passes the name of the form where the code is on to the close command.
 
Or if I do this from the main form, how would I code it? The pop up form is a separate form and not a subform.

Robert

If the close button is on the popup form:

DoCmd.Close acForm, Me.Name, acSaveNo

if the close button is on the main form to close the popup

DoCmd.Close acForm, Forms!YourPopupFormNameHere, acSaveNo

(the acSaveNo has nothing to do with records - it has to do with design changes - in case you were wondering).
 

Users who are viewing this thread

Back
Top Bottom