Unexpected ActiveDatabase

Sure hope I can explain this. The SetActiveDatabase command can unexpectedly be nullified with a simple Message statement. This code is an example:

SetActiveDatabase “A”
Message info(“databasename”) + " " + info(“windowname”)
Call “Re-Calculate Totals”// where “Procedure X” is a procedure in Database “A”

Note that I am using the message statement to help me clearly see the active database and the active window. The above code fails and cannot execute the Call statement, since it cannot find Procedure X. However, the following code does works.

SetActiveDatabase “A”
Message info(“databasename”) + " " + info(“windowname”)
SetActiveDatabase “A”
Call “Procedure X”

Have others experienced this? I apologize if this has already been documented. If so, I could not find it.

The Help page says: “A 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.” I think what you are describing is the intended operation; the message statement returned the active database to the database that ran the code you showed.

The trick is to use nsnotify instead of the message statement. The Notification window that opens is a Mac OS window and not a PanoramaX window so it will not affect the active database setting.

If you use the nsnotify statement instead of the message statement, you get you notification and avoid the problems without the need of another setactivedatabase statement.

Thanks for the clarification and suggestions. A SetActiveDatabase statement followed by Message statement or a Save statement can throw a novice programmer off track. I admit I was quite confused for a while.