ShowModal, Exec a Method and Close - still a question

I am trying to run a group of methods defined in one window from another window and may be making it harder than it is. In any case I set a global variable to a specific value and then exec the called window as window.showmodal. This window then, in the open even, looks at the value of the global variable and if appropriate, it runs a group of methods then closes and returns.

The calling window’s code is:

if dbSQL.CreateDatabaseFile then MsgBox("New SQLite Database File Created") sAccessLevel = "X" //Indicate to xCreateTables to create all tables and return to here (see open event handler) xCreateTables.ShowModal

The showmodal window (called) code is

  if sAccessLevel = "X" then
    bCreateAllTables = True
    CreateTables
    self.Close
    Return
  end if

The code runs okay except the called showmodal window doesn’t go away. It displays (with no visible controls) and sits there until I click the close button and then the app proceeds normally.

Why won’t the called window close and go away?

thanks,

Don’t call Close(), call Hide() and then call win.Close() in the method which has the win.ShowModal() statement (directly after this line).

Is it really necessary to show the window at all? Is it a “please wait” sort of thing because the process is too long? Otherwise, I would agree with your initial assessment that you’re making it too complicated.

A little background, if the app starts and the database file doesn’t exist then I create it. That’s obvious from the code in the original message. The problem comes in when I try to automatically create all the tables the systemlog doesn’t exist yet and it causes an error.

So I tried the following code instead of the original:

if dbSQL.CreateDatabaseFile then MsgBox("New SQLite Database File Created") sAccessLevel = "A" xCreateTables.CreateSystemLog

but when the CreateSystemLog method is called from above, the open even of the window containing the create module executes and I get the error again because the systemlog doesn’t exist yet.

what am I missing here?

thanks

What is the purpose of the xCreateTables window? What does it display?

So calling CreateSystemLog gives an error because the system log doesn’t exist?
Move CreateSystemLOg out of the xCreateTables window and make it a method of the app.
That way you can call app.CreateSystemLog without displaying any windows.
(You will probably find that there are several admin functions that should also follow this route.
It may be that you put them into a module rather than the app object, but you need to divorce them from a window with its Open event.
You don’t get an Open event on a module.

Your xCreateTables shouldn’t assume the file exists.

The xCreateTables window’s Open event can then be

If <file exists> then use it else call app.CreateSystemLog end if