Printing a form from a secret database

Is it possible to make a secret database active, select a record and print that record using a form in the secret database?

Here is the code, It kind of works but it is using a different form than the one specified and no data on the form is showing up

local vRecordID, vReturnWindow

vRecordID = “mytestrecordid”

yesno "Print a copy of a Delivery Slip?"
    if clipboard() contains "no"
        rtn
    endif

vReturnWindow=info(“windowname”)
window “Deliveries”+“:SECRET”
select mRecordID=vRecordID
printtopdf “”,“printer”,“”,“onerecord”,“true”,“form”,“DeliverySlip”,“orientation”,“portrait”,“Height”,“11”,“Width”,“8.5”

window vReturnWindow

I suspect that what you want to do is put the form in the database that you are calling the procedure from, and use the “Database” option for printtopdf to direct the data from the secret database. I think that should work, but I have not tested it.

I haven’t tested it, but looking at the source code for printtopdf I think there may be a bug and it doesn’t honor “secret” windows. However, you should be able to explicitly set the database using the “Database” option.

I am assuming the “DeliverySlip” form is in the “Deliveries” database, correct? That is where it needs to be.