We've already had this not long ago. But your code should now work.
Which line really errors? Use prnjobmain In 0 Shared AGAIN?
1. You checked the alias is not used, so USE prnjobmain without ALIAS clause will open it as alias prnjobmain.
2. the prnjobmain.dbf might be used, but you use it with AGAIN - this
has to work.
Overall: The alias is not used and the file may be used with different alias, but due to using it AGAIN, that won't matter.
To get this error for this line, there would need to be something, which opens the table, but even if that was the case, the table would jsut be used with an alias like B,C,D, a letter corresponding to the workarea number.
So as said, this should never error. Are you sure this is the code erroring and not some other table opening? Do you have an error handler telling you LINE() and PROGRAM() of the error?
Or vice versa, set a break point at the line and step through it to see it happening there.
What you could do is add an alert, if the alias name prnjobmain is not in use after opening the table again:
Code:
If Used('PrnJobMain')
Select prnjobmain
Set Order To jono
Else
Use prnjobmain in 0 Shared AGAIN [b]ORDER TAG jono[/b]
Endif
[b]Assert used('prnjobmain') Message 'prnjobmain.dbf was not opened with alias prnjobmain'[/b]
But even if that is the case you would get the error file is in use in the next run, you would also have all kinds of problems in following code, as you expect you can work with the alias prnjobmain.
Just one thing about this: Asserts and break points and other debugging stuff does not work in the final EXE, only in testing code within VFP.
One other thing is good to know: If you USE some.dbf IN 0 you open the dbf in an empty workarea, but the selected workarea is not the opened table, it's still the workarea selected before the use. If you want to know tha lias name used by USE you do this in two steps instead: 1. SELECT 0, which selects an empty workarea, 2. USE some.dbf (with any further options). The USE will be done in the empty workarea you selected in step 1 and so the workarea will be selected and ALIAS() will tell you the alias name it has got and DBF() will tell you whether it's the DBF file you wanted to open.
Bye, Olaf.