HI Gad,
First of all, you have to write this code in Form.Load or Form.DataEnvironment.BeforeOpenTables (or just add this table to DE).
Form Init usually is too late for this code.
If you have File is in use error, it means, that JobSheet table is already opened by another alias.
Ok, to be 99% save, try this code:
local lcOldError, lnError
lcOldError=on('error')
lnError=0
on error lnError=error()
if used ('JobSheet')
select JobSheet
else
use JobSheet in 0
select JobSheet
endif
on error &lcOldError
if lnError<>0
=messagebox('Table JobSheet can not be opened. Try later...')
return .f.
endif
HTH
>>> if used ('JobSheet') && This alias is already in use
>>> select JobSheet
>>> else
>>> use JobSheet in 0
>>> select JobSheet
>>> endif
>
>When I write the above in the command window (Only the ELSE clause, the used() returns .F. ...), everything works fine. But when I write the same lines in the init of a form I get the "File in Use" ERROR.
>What is wrong?
>
>Many thanks,
>Gadi Hutt
If it's not broken, fix it until it is.
My Blog