Initializedictionary statement doesn't work in a database opened with the opensecret statement


#1

This code:

openfile "Farm management categories"
initializedictionary lvFarmManCatArray,Category,«Sub-category»

works but this:

opensecret "Farm management categories"
initializedictionary lvFarmManCatArray,Category,«Sub-category»

produces an error message, “Field or Variable [Category] does not exist.”


#2

The opensecret documentation says (emphasis added):

The opensecret statement opens a database without opening any windows or launching the .Initialize procedure.

Since no windows are opened, whatever window and database that was active before the opensecret is still active, You can’t use any fields in the just opened secret databases. If you want to do so, add a setactivedatabase statement, like this:

opensecret "Farm management categories"
setactivedatabase "Farm management categories"
initializedictionary lvFarmManCatArray,Category,«Sub-category»

#3

Noted. Thanks Jim.