Hello. I have a project still in RB 2012v2.1. I have run across that I have never seen before before.
In the app.CancelClose, I want to simply do a check of some data and then post a reminder to the user before allowing the app to close. If I add something as simple as a Msgbox to the code first, it seems to completely ignore even an explicit return false and seems to act like I returned true:
[code] MsgBox “not synced”
return false[/code]
If I comment out the MsgBox line it does respond to the explicit false correctly:
[code] 'MsgBox “not synced”
return false[/code]
I have simplified the code above to reduce it to the essence of the issue…down to just one little message box. Any ideas why this is failing?
The code that I want to implement is more complex. My example code as I posted it with the Msgbox causes the CancelClose to be canceled until it is commented out. Remember this is the APP event, not a window. I chose to reduce it down to just a MsgBox thinking that it could not affect other windows.
I will add that this occurs when issuing a Quit from a menu. If the last Window is closed, say with the CloseButton, it runs through the app.CancelClose event first as it should. But instead of failing, it displays the MsgBox and continues to close correctly. IT DOES NOT CANCEL the CLOSE as the other method does using the Quit method.
I am sorry, but I tried your example code in app.CancelClose with RB2012R1.2 on Mac and it quits fine after the MsgBox is OK-ed. That is why I suspect something else is afoot in the rest of your code.
Unless this is on PC and another behavior is there ?
Maybe you could set App.Autoquit to True and simply close all windows after the msgbox ?
Sorry for the delay. I am just getting back to this issue.
After spending a another perplexing good bit of time, I finally had to admit defeat. It was not worth spending more time on. I moved this routine to a Window CancelClose, instead of the app, where it works without issue.
Thanks, Tim, but that is what I wanted to do. I wanted to continue with the Close and it was canceling it when I added any UI activity, even a msgbox, regardless of returning an explicit false.
I handled it another way, so the issue is resolved via a workaround.