I'm not too worried about it as doing the thisform.release like you initially suggested already works. I was just curious as to why calling the _DoCmd did not work when it turns around and does a thisform.release.
Anyhow, I'll just stick with a thisform.release and call it a day!
Thanks so much for your help.
>Rodd,
>
>I'm not sure what the problem is. Anyway, try to move focus of the treeview, to the cancel button, for example.
>
>if keyascii = 27
> thisform.cmdCancel.Setfocus()
> thisform._DoCmd('ESC')
>endif
>
>
>>
>>Our forms all have a common routine called _DoCmd. When Esc is pressed, the cancel button is clicked or when the QueryUnload event fires, they all call _DoCmd with 'ESC'.
>>
>>_DoCmd has the following code:
>>
>>LPARAMETERS cCommand
>>
>>...
>>
>>case cCommand == 'ESC'
>> if p_confirm([Are you sure you want to abandon changes?])
>> thisform.release
>> endif
>>...
>>
>>
>>I can't explain how your solution works. Somehow, _DoCmd gets called with "ESC". Does Release call QueryUnload? If so, how does the above code run without becoming an endless loop when called from QueryUnload?
>>
>>I had tried the following from the treeview control:
>>*Treeview Keypress
>>LPARAMETERS keyascii
>>
>>if keyascii = 27
>> thisform._DoCmd('ESC')
>>endif
>>
>>
>>The problem was, the confirm box popped up twice when I ran my code that way while your code worked. Can you help me understand what is happening here?
>>