Don't use CurrentDataTable(). Ever, if it can be avoided. As you noticed, the current table is set by clicking on a table, and some other possibilities. Apparently the task bar does not count as clicking on the table.
I think you are trying to apply the 'nosave' to forget any changes. (you could also use the setDirty(0) function.) Here's two ways to do it.
First, with a 'this' parameter, a in this example. It holds a window that has a child box that that knows the table.
dt = Open( "$sample_data/big class.jmp" );
dt << onclose(
Function( {a},
Close( (a << child) << getdatatable, nosave );
1;
)
);
Second, by baking in the table:
dt = Open( "$sample_data/big class.jmp" );
Eval(
Eval Expr(
dt << onclose(
Close( Expr( dt ), nosave );
1;
)
)
);
Craige