Based on a previous thread, what I know about secret and shared databases, and Help, it would seem that synchronize would be an un-necessary command after opening the file, and that setactivedatabase might not be necessary, but would not be problematic to include.
In a procedure that opens a shared file, then a single user file, both as secret windows, followed by importdatabase to load the shared data into the unshared file, I’m getting inconsistent results and a wide variety of errors.
Sometimes it works. More often the error is a ‘field or variable does not exist’ error from Panorama but they vary: ActiveProcedure, loggingToServer, hostServer, localCoverage, asyncCallbackLabel… The error may or may not include dimmed menus that require a ForceQuit.
In the simplest code I could pare it down to it’s closing the shared file that sets up the error.
opensecret “SharedFile”
If Error rtn EndIf
opensecret “SingleFile”
If Error
setactivedatabase “SharedFile”
closefile
If Error nop EndIf
Rtn
EndIf
setactivedatabase "SingleFile"
importdatabase "SharedFile","ExistingData","Replace",“MatchingFields”,“YES”
Save
setactivedatabase "SharedFile"
closefile ; <- eliminate this and there’s no issue
If Error nop EndIf
I don’t want the shared file to remain open so how can I close it without an issue?
Which brings up another question. Is there a way to determine what databases are open if they’ve been opened as Secret Windows?
Update: I’ve confirmed that by eliminating all references to CloseFile for the shared file, my full procedure runs over and over without issues. The single-user file can be closed without causing subsequent errors.