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

X

XP

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.
 
W

Wolfgang Kais

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.
 

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