i have to do some forms in visual fox pro 9 for a school project, and if i try to use multiple tables in one form occurs the error> file in use, even if i try to use the command "use thistable" "use secondtable" before the code, then i can not close the form at all. these are basically my codes in different command buttons but it doesn't work>
command1:
USE camera
SELECT camera.nr_camera, camera.ocupat, camera.tip_camera FROM camera WHERE camera.ocupat=.F.
command2:
USE rezervari
APPEND BLANK
replace id_rezerv WITH thisform.text1.value, id_client WITH thisform.text2.value, data_intrare WITH thisform.text3.Value, data_iesire WITH thisform.text4.value, nr_nopti WITH thisform.spinner1.value, nr_camera WITH thisform.spinner2.Value, mic_dejun WITH thisform.check1.Value
thisform.text1.Value=0
thisform.text2.Value=0
thisform.text3.Value=SPACE(20)
thisform.text4.Value=SPACE(20)
thisform.spinner1.Value=null
thisform.spinner2.Value=null
thisform.text1.SetFocus
thisform.Refresh
does anyone know what should i try? i even tried to use then close the table but it still won t work
                        
When you want to do an SQL
Selectin Vfp, you would Not need to use theUsecommand in advance. So your code could look simply like:Set Exclusive Offbefore you would open any table implicitly, as an SQLSelectwould do, then that implicitly opened "Alias" would get opened in Shared mode too. WhereSee also the F1 Help chapter on that topic.
When you want to open an
dBase/xBasetable in FoxPro programmatically, you'd normally do that in Shared mode, and inside the next unused so called work-area:... Where the
Use Againmeans "even when that table is alreadyUsed()as anotherAliasname"The code you posted is a little misaligned. You could however simplify the entire Use/Append Blank/ Replace sequence with a single SQL
Insertline:Even easier would be to add the desired table alias to the DataEnvironment of your Form, and then add string expressions like "rezervari.id_rezerv" to the
ControlSourceproperties of your Controls in the VFPForm Designer. That way yourFormand itsDataEnvironmentand its Controls would do all the work for you, much less code-behind required. That's basically what the "Visual" invisual-foxprois all about.