old_alias = ALIAS()
flag_use = .f.
IF .NOT. USED("Table1")
SELECT0USE table1
flag_use = .t.
ENDIF
....
&Your code here
IF flag_use
USEIN table1
ENDIFIF .NOT. EMPTY(old_alias)
SELECT (old_alias)
ENDIF
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller The only thing normal about database guys is their tables.