Avatar of Juan Ocasio
Juan Ocasio
Flag for United States of America asked on

Canceling excution of all code when end user select x at top of form

Hello all:

I have two forms (MS Access 2010).  The main form allows an end user to select certain materials.  Once they select an item and then press 'Process', it the material has serial numbers, it displays the second form (acDialog), so the end user can select the serial numbers they're processing.  What I would like to happen is if an end user clicks the x at the top of the second form (the serial number selector), I want all execution to stop.  I thought if I create an Err object it would do that, but it throws the error and then continues execution on the main form.  Is there a way to completely stop execution of the code?

Many thanks!

Juan
Microsoft Access

Avatar of undefined
Last Comment
Juan Ocasio

8/22/2022 - Mon
SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Dale Fye

I prefer not to use the close button of the popup (I actually disable it) and instead use a Cancel button.

One of the neat things about the acDialog value in the WindowMode is that the code on the main form will pause until you have closed (or hidden) the popup form;  the key here is "or hidden"!  The way I use this is to place a cancel button on the popup form and hide the form in when that button is clicked.  I then use code like the following in the main form.

docmd.OpenForm "frmPopup", acNormal, , , ,acDialog
if currentproject.allforms("frmPopup").isloaded then
    docmd.close acform, "frmPopup"
    Exit sub
endif
'otherwise, continue
Dale Fye

Jim, I noticed you looking at the post before I hit send, but did not think to refresh the page before I did so.
Jim Dettman (EE MVE)

no problem and Juan is sure he has a good answer now<g>

Jim,
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Juan Ocasio

ASKER
Thank you both for your input.  How do you set the dialog's hidden prop to true?  I can't seem to find the correct property.

Thanks!

Juan
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Juan Ocasio

ASKER
I got it.  Thanks for both of your help!
Juan Ocasio

ASKER
I hope I've awarded the point equally.  It appears to be a bit different.  You both were extremely helpful!

Thanks again!

Juan
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.