Pasting code that's not cleaned up properly causes confusion :) In my case I save the 'users' path to a table. When populating the property first I do something like :
1)
select DataPath from myDataPathTAble into array arrDataLoc
arrDataLoc was coming from there.
2) If you've multiple path and databases you might tweak the code getting relevant table paths. ie:
oApp.Apppaths[1] = 'c:\UserDataPath\Folder1\MyDBC1.dbc'
oApp.Apppaths[2] = 'c:\UserDataPath\Folder1\MyDBC2.dbc'
...
CursorX.Database = 'c:\MydevelopmentPath\Folder1\MyDBC1.dbc'
for ix=1 to alen(oApp.AppPaths)
if upper(JustFname(oApp.AppPaths[m.ix])) == ;
upper(JustFname(CursorX.Database))
CursorX.Database = oApp.AppPaths[m.ix]
exit
endif
endfor
As per opening each form and putting this into beforeopentables I've :
Local lnForms,ix
Local Array arrForms[1]
lnForms = Adir(arrForms, "forms\*.scx")
TEXT to m.lcMethod noshow
PROCEDURE BeforeOpenTables
UpdateDE(this)
ENDPROC
ENDTEXT
For ix=1 To lnForms
Use ('forms\'+arrForms[m.ix,1])
Locate For Atc('dataenvironment',BaseClass)>0
If !Eof()
Replace methods With m.lcMethod
Endif
Use
Compile Form (arrForms[m.ix,1])
Endfor
That checks each form and if has a DE than pokes BeforeOpenTables code.
PS: Of course before running this code first I check if they have DE and code in BOT what's that :)
Cetin
>Hi, Cetin
>
>Thanks very much for the help and the sample code. I did want to avoid putting code in all my forms to get around this problem (there are loads of them) but, from the 3 replies I've received, it seems that this is all I can do. It's a shame I can't put the code in my form class, as it doesn't have a DE. Your example would seem to be the least disruptive as it only requires the "UpdateDE( this)" putting in the .BeforeOpentables().
>
>Yes, I am using private data sessions.
>
>I have a few questions about the code, if you wouldn't mind:
>
>1) In the MyAppClass.prg you have the line
>> This.cAppDataPath = arrDataLoc
>What is "arrDataLoc"? I'd assumed it's one of those define fields from a .h file but I've no idea which.
>
>2) As my databases are in 3 different sub-folders I can't just assert a database folder. It depends on which sub-system the user wants. To further complicate matters, some forms use tables from more than 1 database (sometimes all 3!). Can you think of a simple tweak to your code that would accommodate this (I guess I'll gert there eventually but you might have the answer to hand)?
>
>Thanks for your continuing help.
>
>Terry