I want to have a msgbox ask if files have been backed up, and if they aren’t (answer is no), I want the operation to close. I have this code in the open event of a window:
If 6 <> MsgBox ("Warning. Are Your Files Backed Up?", 36) Then
I would think this’d work, but it apparently doesn’t. I call a method from another window and of course it goes to open. But instead of closing the window it continues on to the method. The debugger does course thru the close window event, but it continues afterwards to that method. Is there something I’m missing?
Is there more code in the method that calls the window.open event that might be running and opening the window again?
For example, if you have
Window.loadStuff will run on the window AFTER it has been closed (within the open event), which could cause it to open again if you’re using an implicit instance of the window.
Thanks. I moved the code to the end so that code works and it improved stuff, but it didn’t stop the method from being called. Also, in close, I have stuff:
App.WinOpen(2) = False//which window is open
I like implicit instance, but maybe I have to get rid of it. It doesn’t make sense. Suggestions?
I put in
If App.WinOpen(2) Then BatchImport.aUpdateMultiple(MnStuff.DocFolder)
It worked but I don’t understand the need. It’s easier than using new though.
You really can’t close a window from its Open event. You’re right in the middle of some framework code. The correct sequence is to not open the window in the first place.
Thanks. I was hoping to avoid redundant code, but you’re right.
Or have a timer on the window that closes the window/
It runs on a VERY short timer (a period of 0 or 1).
When you figure out you want the window to NOT open then you have this timer enabled & it does nothing other than self.close when its action runs.
That may have some odd effects like the window showing up & immediately closing though.
The better option is to have the code that would open the window determine that it should not open the window because the condition has not been met.