Another set of eyes

I need another set of eyes on the following code:

Local W
W = Info(“WindowName”) //Financing is the active database
Message Info(“DatabaseName”) + “Message 0” // This give me the name: Financing Message 0

OpenSecret “ProForma”
Window “ProForma:Secret”
Message Info(“DatabaseName”) + “Message 1” //This gives me the name: ProForma Message 1 Message Info(“DatabaseName”) + “Message 2” //This gives me the name: Financing Message 2
Stop

I must be missing something. Why does the active database change back to Financing between Message 1 and Message 2?

Good question. I have also found that it is not obvious when the secret database is active, and one must pay attention that issue when writing a procedure. According to the Help page for the open secret statement, the secretly-opened database “… remains the active database until the procedure ends, until another setactivedatabase statement activates another database or until the visible window changes, such as when a message or alert is triggered. The use of the save statement has the same effect.”

Instead of using a message statement you could use an nsnotify statement which uses a system window and not a Panorama window. This will not alter the active Panorama database setting.

This has come up on the forum before. After you use a message statement, the topmost window becomes active. So you cannot use a message statement if you want to continue using a “secret” window.

You can - just follow the message statement with a

setactivedatabase "your database name in quotes"

Thank you for all the help and suggestions. My original question was stimulated by a strange behavior in one of my procedures. The procedure would run perfectly when triggered by the Run Button in the procedure window, but it would not run properly when triggered by entering or modifying data in the DataSheet view. In my feeble mind there should be no difference. I wonder if anybody else has experienced the same phenomenon?

If your procedure is switching between windows, that is not allowed when triggered by entering or modifying data. One way you can get around that is to put the code into a timer set to repeat only one time.

However, I wouldn’t recommend this as switching windows just because data has been entered is going to be a horrible user interface experience.