I have a form calling a secondary form. In order to close the latter I have to click twice the button that has the following statements in the CLICK method:
ACTIVATE SCREEN
"CLICK fired "
THISFORM
.Deactivate ()THISFORM
.Destroy ()THISFORM
.Hide()THISFORM
.Release()4 statements are there out of desperation. I tried them separately and in many combinations. I see on the SCREEN that the event fires accurately. I tried to put these statements into MOUSEDOWN - the same thing. I can see that that event also fires. I tried to place them in both methods. The behavior changes somewhat. The secondary form seems to disappear for a flicker and then comes back again like it was activated from the main form--this is not realistic. The second click kills the form.
Any thoughts
Thanks.

a child form needs 2 clicks to close
Sahil Jain
NO, it did not work and in fact messed the whole app up completely. I had to crush the fox to get out because everything was in a hungup state.
I am getting a bit nervous about it. It should be a fairly common situation and how come nobody else has not complained about it previously The only thing "unusual" about this form which I tried to eliminate (and it did not help a bit) was that two parameters were passed to it and they were the .top and .left of the main form. Thus the child form uses those coordinates to position itself not too far away from the main one, or rather right on top of it (the child form is much smaller). As I said elimination of this assignment did not help.
Is it a bug or I am seeing things I am not too eager to get on record as a bug catcher, it is just helpful to know what it is.
I wll try to create two other forms with no controls at all, just two buttons calling one another.
Spectrum
Did you have a clear events in the click event or valid of the button
What happens when you click on the X on the top right of the form
Don
manik
It is a simple form. I will try your idea in a minute.
Thanks.
Steve Billingsley
Anand S N
Hello Don.
The valid is preferred because the click method does not fire with the keyboard
I am sorry, but you are mistaken. The Click event fires when you use the hot key (if any) associated with the button or when you tab to the button and press < ENTER >.
As a matter of fact, all my command buttons have the code in their Click() methods (well, actually, in a custom method called OnClick() which is called from the click) and they all work just fine.
Neax
Hi
Don't use the clear events. thisform.release is a good solution.
Try to put this in the form's keypress event:
LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 27
thisform.Release
ENDIF
Is it s simple form or a formset
Kristof Pauwels
The valid is preferred because the click method does not fire with the keyboard.
Move this code into the Valid event:
clear events
thisform.release()
All will work unless there is more to the story than explained.
Don
Softpen
clear events
This would be a bad move. This is a child form popped. Issuing a Clear Events here stops event processing. I do not think that the goal is to end the application when the child form is closed....
<<<
My Bad, I forgot he was not in the main form. Good point.
Don
Chinh Nguyen
LPARAMETERS
nKeyCode, nShiftAltCtrlIF nKeyCode = 27
thisform.Release
ENDIF
This is totally unnecessary. All you need to do is set the cancel property of the exit button to .T. This does the same thing as your code with no code required.
wayne-o
Thus the child form uses those coordinates to position itself not too far away from the main one, or rather right on top of it (the child form is much smaller). As I said elimination of this assignment did not help.
I do this sort of thing all the time with no problem at all.
Is it a bug or I am seeing things I am not too eager to get on record as a bug catcher, it is just helpful to know what it is.
If this is a bug, it is a bug in your code. I call modal forms from command buttons all the time and they release with no problem. All I do is put
Thisform.Release()
in the click of the command button.
Is there any code in the form or up the class hierarchy in the form's Deactivate, destroy or release methods
CSCNavy
ThisForm.Release()
If that's not working, then something else in your code is interfering. Most likely, there are object references preventing the form from being release.
Tamar
Tiger Wong
In the CLICK method. I should think about using VALID. I've never done it.
Thanks
dariuslovhalll
I should have mentioned that but forgot: this contingency has been thought of and take care. It is a simple form containing a listbox and a "CLOSE" button. The listbox's RowSourceType is 6 and RowSource is a field in a table. Before those 4 statements I have a statement setting the rowSource to .NULL.
There is nothing else in this form that seems to be causing the problem. Obviously, you are right, there is something in there but what This is why I am asking anyone to come up with any sensible guesses.
Thanks.
local
Move this code into the Valid event:
clear events
This would be a bad move. This is a child form popped. Issuing a Clear Events here stops event processing. I do not think that the goal is to end the application when the child form is closed....