Is there a way through the .initialize procedure that when the database opens it closes all open windows and form and opens only one form called “Data Entry”. I have put "OpenForm “Data Entry” in the .Initialize and it works just fine and opens the the Data Entry form, but the other open one(s) are behind it.
This comes to mind in the .Initialize procedure:
makesecret setactivedatabase "MyDatabase" // use the name of your database openform "Data Entry"
That should open the form ok but he also wanted to close all open forms ahead of that…
Thank you, yes you are correct. I want to close all other forms other than the one I specify in the .initialize statement.
And that is what the makesecret statement does. It closes all open windows but keeps the file open in menory. The setactivedatabase statement then make the secret database the active database so that the following openform statement can open only the desired form.
oops! I sit corrected
Thank you Gary. That did the trick. I appreciate the help.
A slightly different approach will close windows instead of just hiding them. I at one time posted code to do this, and Jim made some improvements to it. So this code is mostly or entirely from Jim.
let otherwindows = arrayrange(info("windows"),2,-1,cr()) looparray otherwindows,cr(),otherwindow // is this window in the same database as original window? if windowinfo(otherwindow,"database")=info("databasename") // bring window forward, then close it window otherwindow closewindow endif endloop
I use this to close windows before closing the database so the next time I open it I don’t get a bunch of unwanted windows opening.
MakeSecret doesn’t just hide windows. It makes the database itself secret by closing all of its windows without closing the database itself. Because it no longer has any open windows, it is no longer active. That’s why Gary included the setactivedatabase statement.
Thanks for that explanation. I see that I had an incorrect understanding of makesecret, but not any more.
openform statement was enhanced in Panorama X with additional options, one of which performs the same function as the
setactivedatabase statement. So Gary’s example can be made one line shorter!
makesecret openform "Data Entry","Database","MyDatabase"