View Full Version : cancelling an update on a form that doesn't have focus


jatfill
06-24-2001, 06:57 AM
Hi all,

I'm creating a registration form, and I've set it up the following way:

User enters the contact's first and last name. Once the last name field is completed, I run a check to see if any matching names already exist in the contacts table. If there are matches, a message box appears informing the user that he contact they are trying to add may already be in the system.

If they press OK on the message box, a list box form appears with all of the matching names with a summary of their address and location so the user can verify whether or not the contact already exists; if the user presses cancel, they simply continue working.

On this list form, if the user double clicks on a name, it takes them to an edit form for that contact and closes the addition form they were working in (if they press cancel on the list results form, they are also taken back to the add form to continue working.

Now on the add form, I'm running several Before Update checks to make sure data is not missing or invalid... but when they close the registration add form by selecting a matching user on the list results form, the validation checks run and it tries to add the user.
What would be the proper way to cancel the addition and close the add form when the form does not have focus (i.e. running the cancel/close for the add form on the On Dbl Click properties of the list box).

I hope that was clear. Thanks in advance!

Fornatian
06-24-2001, 08:45 AM
try:

Forms("YourForm").SetFocus
DoCmd.RunCommand acCmdUndo
Docmd.Close acForm "YourForm"
Forms("TheOtherForm").SetFocus

may work, haven't tried it but looks promising.

Ian

jatfill
06-24-2001, 08:53 AM
It's having a problem with this line:

Docmd.Close acForm "YourForm"

It says something like "Error: Excpected Array"

I just changed it to "DoCmd.close" and it worked perfectly... thank you very much for the tip!!