Also yes, the z_DashboardViewTimeSpanFrom, z_DashboardViewTimeSpanTo (mistyped that in the original post), and z_TextActive variables are all Global, I'm sure of that
I suspect that a script trigger is performing yet another script that then produces the error message.
What layout do you see if the Go TO Layout step is not performed?
Check that layout for script triggers, especially an OnLayoutExit trigger.
Your script also might be tripping an OnLayoutEnter or other script trigger on the Dashboard layout.
Such changes in layouts might trip a number of different script triggers when you open the file, but if you run the script with the dashboard layout already selected as the current layout, they won't.
It opens the "Orders List" layout, which I assume is because that was the last window opened on the host computer.
There is no OnLayoutExit script trigger for that layout, nor is there an OnLayoutEnter script trigger for the Dashboard
BUT there is an OnLayoutEnter script for the Orders List layout. It runs "FilterOpenClosed" which is:
Show All Records
If [z_Search::z_OrderList_ShowOpen = "Open"]
Constrain Found Set [Restore]
Else If [z_Search::z_OrderList_ShowOpen = "Closed"]
Constrain Found Set [Restore]
Sort Records [Restore; No dialog]
All the values used there are Global too, or part of the Orders table.
z_Search and Database are both instances of a table called z_Resources, which I keep mostly variables and things to run the backend of the system... maybe they conflict?
Also if I run the OpenDatabase script from the Orders List layout while the database is already open it works with no error.
I went back to the OpenDatabase script and added a Go to Layout ["Orders List"; Orders] before the Go to Dashboard action and it still worked without errors.
Please note that OnLayoutExit and OnLayoutEnter are the most likely suspects, but other scripttriggers may be tripped by a change in layout.
maybe they conflict?
They won't conflict but your table occurrence context--as determined by the current layout, may make one or both of them inaccessible to steps in your script at the moment that they execute.
If you had FileMaker Advanced, I'd suggest the following:
Launch filemaker advanced without opening the file.
Enable the script debugger.
Open the file and step through the script steps one step at a time until the error dialog appears.
Sadly we don't have Advanced :/
But you did help me narrow it down to that OnLayoutEnter script! When I disabled it on the Orders List the error went away at startup. I'll investigate further later... Might just ignore it and just add a script to go to a safer Layout before switching to the Dashboard.
You know what I think it might be...
The OnFirstWindowOpen script trigger in the File Options probably takes precedence over the layout's OnLayoutEnter trigger, but it still queues the OnLayoutEnter script to run after the OnFirstWindowOpen script, even if it goes to a different layout.
That's my guess. I've got to head off to another client now, but thanks for the help Phil!