I’m documenting this here to help anyone else who runs across this weird set of circumstances. I’ve written an action button on a form that writes a series of data to a sequential file. Before writing to the file, this button updates a field value on the document, then calls uidoc.Refresh, uidoc.Save. This is done to make sure the front-end and back-end documents are identical. This form has an embedded view on it that uses a formula for the embedded view selection.
When I click this button for the first time after opening the form, it runs as expected. The second time I click the button, I get an error on the first “Print #” statement following the uidoc.Save. This error says “File not open”. When I moved the Refresh and Save calls to the end of the button code (after all of the file writing is done and the file is closed), the button works fine. When I tried using a static embedded view, this button also functioned properly (prior to moving the Refresh/Save code to the end).
It would seem that there is some problem with the combination of using the formula for embedded view selection, the uidoc.Refresh/Save, and the file handling process.
Hope this saves someone some time in the future. Keil.