Mysterious unrelated table error
I have an OpenDatabase script that when I first open the database, it causes the unrelated table error:
"This operation could not be completed because the target is not part of a related table"
The script does the following:
Set Window Title
Enter Browse Mode
Go to Layout ["Dashboard" (Dashboard)]
Set Field [Dashboard::z_DashboardViewTimeSpanFrom; Get ( CurrentDate ) - Time ( 24*30 ; 0 ; 0 )]
Set Field [Dashboard::z_DashboardViewTimeSpanFrom; Get ( CurrentDate )]
Set Field [Dashboard::z_TextActive; "Active"]
Now using an If  statement I narrowed it down to the "Go to Layout ["Dashboard" (Dashboard)]" step that's causing the problem, but I can't understand why. Shouldn't the Go to Layout action not care about related tables?
I checked for any script triggers that may be erroneously loading and couldn't find any...
To add to the mystery, if I just try to run the script while the database is already open, no error. So it's something specifically in the database startup that's causing the problem...
So what could be happening? What can I look for?