I have a Popup Menu Button Object in a form. I wish to use it to choose which of the available databases to open. Its Formula panel contains this code:
replace(arraystrip(arrayfilter(listfiles("",".pandb"),cr(),{?(import() contains "biglookup","",import())}),cr()),".pandb","")
and the popup list displays the available databases.
The Special Object Properties panel (aka the “magic” panel) looks like this. The variable, mgPrimaryDatabase, has been declared as a global in the .Initialize procedure:
:
The Procedure panel contains this code:
if arraysearch(info(“files”),mgPrimaryDatabase,1,cr()) = 0
; file is not open
alertyesno "The " + mgPrimaryDatabase + " database is not open. Do you want me to open it for you?"
if info("dialogtrigger") = "No"
mgPrimaryDatabase = ""
showwindowvariables mgPrimaryDatabase
stop
else
opensecret mgPrimaryDatabase
setactivedatabase mgPrimaryDatabase
call .Initialize
if error nop endif
Window mgWindowName1
endif
endif
If I choose a database which is not open, this message is displayed:
If I click “Yes”, this message is displayed"
A message info("files")
statement shows that the selected file is open, so it seemed possible that the setactivedatabase mgPrimaryDatabase
statement was causing the problem. I inserted a message "1"
statement before the setactive
statement (without changing anything else) and the error message was no longer displayed - everything was fine. A message after the setactive
statement had no effect and the error occurred.
Removing the setactive
statement also got rid of the error message.
I’ve tried to give all of the information that might be needed to solve this problem. Can anybody tell me why it’s happening?