Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form.Close
Hi,
I'm having trouble detecting how a Form Closes. I want to allow whatever is done to be cancelled (if the Forms Close button is used) but as the .Hide and form unload routines always run I can't tell if it closed via my code, or by the close button. This HAS to be simple but I can't figure it ! Any suggestions? Thanks - Kirk |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form.Close
On Tue, 10 Feb 2009 15:51:58 +1300, kirkm wrote:
Hi, I'm having trouble detecting how a Form Closes. I want to allow whatever is done to be cancelled (if the Forms Close button is used) but as the .Hide and form unload routines always run I can't tell if it closed via my code, or by the close button. This HAS to be simple but I can't figure it ! Any suggestions? Thanks - Kirk SORRY ! Ignore the above... figured it out. A boolean varible set False in Form initialise. Then set True if any Form events occur. But if there's any way to detect Close Button fired That's the X on Form Top right, it's be useful |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form.Close
hi
the code you wrote is closing the form. the question becomes .....which code did you write that is closing the form. forms don't close themselves for no perticular reason. since you didn't post your code for us to analize... have you tried step mode to see which code you wrote is closing the form???? i doubt the close button came with built in code. Regards FSt1 "kirkm" wrote: Hi, I'm having trouble detecting how a Form Closes. I want to allow whatever is done to be cancelled (if the Forms Close button is used) but as the .Hide and form unload routines always run I can't tell if it closed via my code, or by the close button. This HAS to be simple but I can't figure it ! Any suggestions? Thanks - Kirk |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form.Close
Do you mean the X in the top rightcorner?
If yes, then maybe you could just call the cancel button's code: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Call CommandButton2_Click End If End Sub Or just stop it completely???? Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then msgbox "Don't use that X" cancel = true End If End Sub kirkm wrote: Hi, I'm having trouble detecting how a Form Closes. I want to allow whatever is done to be cancelled (if the Forms Close button is used) but as the .Hide and form unload routines always run I can't tell if it closed via my code, or by the close button. This HAS to be simple but I can't figure it ! Any suggestions? Thanks - Kirk -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form.Close
hi
sorry. i assumed that the close button was a button on your form. be more persise in your posts so that nothing can be assumed. sorry i could not help. see dave's post. i think even he may have been a tad confused. Regards FSt1 "kirkm" wrote: On Tue, 10 Feb 2009 15:51:58 +1300, kirkm wrote: Hi, I'm having trouble detecting how a Form Closes. I want to allow whatever is done to be cancelled (if the Forms Close button is used) but as the .Hide and form unload routines always run I can't tell if it closed via my code, or by the close button. This HAS to be simple but I can't figure it ! Any suggestions? Thanks - Kirk SORRY ! Ignore the above... figured it out. A boolean varible set False in Form initialise. Then set True if any Form events occur. But if there's any way to detect Close Button fired That's the X on Form Top right, it's be useful |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form.Close
On Mon, 09 Feb 2009 21:14:03 -0600, Dave Peterson
wrote: Do you mean the X in the top rightcorner? Yes... don't know what it's real name is so I called it the 'close button'. (Hoping that would distinguish it from a VB command.) If yes, then maybe you could just call the cancel button's code: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Call CommandButton2_Click End If End Sub Aha! That's exactly what I spent hours trying to code around. Works perfectly. Thanks a million! Must remember that! Cheers - Kirk |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form.Close
On Mon, 9 Feb 2009 20:53:02 -0800, FSt1
wrote: hi sorry. i assumed that the close button was a button on your form. be more persise in your posts so that nothing can be assumed. No worries... can be hard to describe something when you can hardly figure it out yourself! I'll try though... this one now nicely sorted. Thanks for helping. Cheers - Kirk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Close a form when you click outside of the form | Excel Programming | |||
Call user form from ThisWorkbook; close file if form closed | Excel Programming | |||
How do I close form | Excel Programming | |||
Close form... | Excel Programming | |||
Close Form with VBA | Excel Programming |