I have a procedure, say MyPrintProcedure, in Database A that selects records, groups, and totals some fields, then printtopdf makes a file using a report form.
But if I have a procedure in Database B that changes the active database then calls the procedure, the printtopdf statement malfunctions (at least it doesn’t do what I want). The code in Database B is,
setactivedatabase "A"
call "MyPrintProcedure"
The result is that the selecting, grouping, and totaling work correctly. But the resulting pdf file is very different. It looks like the active database switched back to Database B and printed the report using the data from Database B and the form from Database A. Using zlog statements confirmed that the active database immediately before the printtopdf statement was database A, and immediately after was Database B. Based on the data in the report, the switch occurred before the report was created. I could not find the code in the libraries for printtopdf to see what was happening.
It seems to me that what I tried to do should work, but perhaps there are reasons why that is not a good idea.