Form to close itself after double-click event in a control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using Office 2003 and Windows XP;

I have a form with a control that a user may double click to open another
form containing a list of values. Double click this list and it copies some
data back to the original form. This all works great...except...I can't get
the second form to close itself.

Included in the double click event of the second form, when selecting a
choice from the list, I placed the following code lines:

Dim sFormName as String
sFormName = Me.Form.Name
DoCmd.Close acForm, sFormName, acSaveNo

But this does not work...I also tried:

DoCmd.Close acForm, Me.Name, acSaveNo

And this doesn't work either. How can I get the form to close itself?

Thanks much in advance for your assistance.
 
Hello "XP"

XP said:
Using Office 2003 and Windows XP;

I have a form with a control that a user may double click to open
another form containing a list of values. Double click this list
and it copies some data back to the original form. This all works
great...except...I can't get the second form to close itself.

Included in the double click event of the second form, when
selecting a choice from the list, I placed the following code lines:

Dim sFormName as String
sFormName = Me.Form.Name
DoCmd.Close acForm, sFormName, acSaveNo

But this does not work...I also tried:

DoCmd.Close acForm, Me.Name, acSaveNo

And this doesn't work either. How can I get the form to close itself?

Thanks much in advance for your assistance.

The user doesn't doubleclick the second form but a control, therefore
the code should be placed in the doubleclick event fot that control.
Place the code directly after the code that writes the data back to
the first form. The line "DoCmd.Close acForm, Me.Name, acSaveNo"
should work, except if that form is a subform...
If so, use "DoCmd.Close acForm, Me.Parent.Name, acSaveNo" instead.
 
Back
Top