Power Forms - Stop form from closing when OK button is pressed

BOster

BOster

Legendary Poster
How do you stop a form from closing when the OK button is pressed aside from setting an error on a control?

Scenario:
I have a powerform parent that has several subforms one of which is an editable grid. When the user moves off a line in the grid, data validation runs and throws errors in the grid, etc. However, nothing stops the user from pressing the OK button on the parent form and closing the form. If the grid was on the parent form, then the error(s) would prevent the form from closing, but since the error is on a child subform, nothing stops the user from closing the parent form.

I am able to use the subform system function on the parent to get the error count on the subform but once I have that error count the only way I can prevent the parent form from closing is to throw an error on the OK button of the parent... which is kinda ugly. It would be nice to get the error count of the child subform and then simply stop the OK.post event and prevent the parent form from closing and firing all the associated form closing events.
 
Two suggestions:
a) Perhaps the disable control system function for the OK button will work. And then enable control after the errors are cleared.

b) Another option would be to create a fake OK button, hide the real one and have the fake button trigger the real button if there are no errors.
 
Boster,

Not a fun scenario.

I don't have a Powerform up in front of me, let's see what I can recall from my hydrocodone induced memory....

- Add a Math field to subform (to work as your error counter)
- when errors are identified, start adding up the counter
- trip a 'notify parent' event
- When the parent is notified, While the counter is != 0, disable the OK button
- While the Counter = 0, enable the OK button
- allow the Cancel, in the event they want to... you know, cancel....

Busy-work, yes. I did something 'similar' a few months ago. If I can come up with the exact logic - I'll update more.

(db)
 
Both good suggestions. (B) would almost certainly work, I was just trying to avoid it. I would like the default OK button since users are used to it.

(A) wont work because if the user is editing a single grid row and then, w/o exiting the row, clicks the ok button, the code on the ok button to disable the ok button doesnt prevent form from closing. In other words in this scenario:

1. User fills in grid fields and clicks ok (w/o exiting grid row)
2. row exited-inline fires throws errors
3. code on ok button fires, gets error count disables ok button, but form closes anyway
 
A good idea, but this is somewhat similar to other posters suggestion but wont completely work (see my other post as to why it wont work).
 
Boster,

A slight twist:
- Disable the OK Button, at the Control is Entered event (add 1 to the counter and Notify Parent).
- Don't enable, until the row is validated and gives no errors?

(db)
 
I think that standard way to intercept error in this case is to use the system functoin that you mentioned in you first post. Why don't you like this way?
 
Luigi,

In most cases, within a subform, the errors are not shared between the mainform and the subform. Makes for stinky issues in many many occasions.

Usually, it's best to make the assumption that everything needs to pass through the data structure (both ways) - for activities between the forms. Think of it similar to any form interconnect (only, 'usually', easier).

(db)
 
[ QUOTE ]
I think that standard way to intercept error in this case is to use the system functoin that you mentioned in you first post. Why don't you like this way?

[/ QUOTE ]

The issue is not finding out if there are errors on a subform. The issue is stopping the form from closing when there are errors.
 
[ QUOTE ]

A slight twist:
- Disable the OK Button, at the Control is Entered event (add 1 to the counter and Notify Parent).
- Don't enable, until the row is validated and gives no errors?


[/ QUOTE ]

Some form of disabling/enabling the OK button would probably work. But then it opens up a lot of holes to plug and a lot of parent/child messaging, etc. I think I am simply going to move forward with setting an error on the OK control when the user clicks OK and there are errors on child sub-forms.

FYI. I experimented with setting and then immediatly clearing the error on the OK button to try and stop the form from closing w/o displaying an error, but not matter how I implemented this technique, it closed the form. I think that as long as there are no errors on a parent form control by the time the chain of ER code finishes executing when the OK button event is fired, the form will close. Just in case you are curious, my most elaborate attempt (that still didn't work) was the following:

- Parent From OK clicked event: 1) Set error on FC, 2) Send message to subform
- Child Subform Parent notify event, send message back to parent to trigger notified by child event in parent
- Parent Notified by Child evnet: clear FC error


IMO, Oracle either needs to provide us with a system function to stop a form from closing or have the parent form behave the same way when there are errors on child subforms as it does when there are errors on the parent form.
 
[ QUOTE ]
... the only way I can prevent the parent form from closing is to throw an error on the OK button of the parent... which is kinda ugly.

[/ QUOTE ]

I'm wondering why you find this approach ugly? It seems like a fairly straightforward means of achieving what you're trying to accomplish. I guess you get an 'extra' error in the error list, but it could be worded in such a way so it doesn't appear to be an 'extra' error to the end-user...kind of a notification that errors were detected on the subform.
 
[ QUOTE ]
Some form of disabling/enabling the OK button would probably work. But then it opens up a lot of holes to plug and a lot of parent/child messaging, etc. I think I am simply going to move forward with setting an error on the OK control when the user clicks OK and there are errors on child sub-forms.

[/ QUOTE ]

Sorry, I didn't see this post before I started and submitted my previous post...

[ QUOTE ]

IMO, Oracle either needs to provide us with a system function to stop a form from closing or have the parent form behave the same way when there are errors on child subforms as it does when there are errors on the parent form.

[/ QUOTE ]

Agreed!
 
[ QUOTE ]
I guess you get an 'extra' error in the error list, but it could be worded in such a way so it doesn't appear to be an 'extra' error to the end-user...kind of a notification that errors were detected on the subform.

[/ QUOTE ]

How about this for my error message:

"Well, well, well, did you really think you could click OK? Did you really think you were done? Just look at all these errors... go fix them you MORON, and then maybe, just maybe I will close the form for you and let you move on with your life!!!!!"
 
Sounds like a good idea. And even after the errors are cleared add a few more message forms,
first one asking, "Are you sure ?", next "Are you really sure ?",..."Think again",..."Haste makes waste, sure ?" and so on
grin.gif
 
[ QUOTE ]
Sounds like a good idea. And even after the errors are cleared add a few more message forms,
first one asking, "Are you sure ?", next "Are you really sure ?",..."Think again",..."Haste makes waste, sure ?" and so on
grin.gif


[/ QUOTE ]

LOL. Development would be easy if it wasnt for those pesky users....
smile.gif
 
Hi

Would you mind saying what your final solution / way forward on this one was?

Thanks
 
Not 100% sure since this was so long ago, but my guess is that I checked the subforms for errors and if any were found threw an additional error on the parent form's OK button.
 
Back
Top