>Is there something that could be done with name expressions? Something like
>
>FileLocation = "c:\data\"
>
>then
>
>OPEN DATABASE (FileLocation + "db_name")
>
>?
>
>Joe
>
>
>>>>Does anyone know how to point a form's data environment
>>>>to different data directories dynamically?
>>>>
>>>>I'm trying to enhance my current framework to handle
>>>>multiple 'Companies' each with data in different
>>>>directories, but with the same structure.
>>>>
>>>>Thank you,
>>>>Chris Holtz
>>>
>>>Hi, Basically, VFP with Due with the Current Working Directory.
>>>i.e. You can assign to what directory as you wish by:
>>>
>>>SET DEFAULT TO H:\happyDir
>>>
>>>Remember if You use a CommonDialog to open a file out of the orginal one...
>>>You need to use:
>>>CD H:\happyDir
>>>to restore to original Directory!
>>>
>>>Or even simple add this 'CD' command at the beginning of program!
>>>It is more comprehensive if you set all your favour setting at the beginning
>>>of program and you nearly don't change them unless special reasons.
>>>
>>>Then, you can adjust them well.
>>>For example, you can:
>>>SET DELETE ON
>>>SET ANSI ON
>>>SET EXACT OFF
>>>CD H:\happyDir
>>>....
>>>* Then, really start you Form
>>>Do Form HappyNow With "Have a Nice Day!"
>>>.....
>>
>>This could work with free tables but would fail with DBC. DBC is hardcoded in DE and should be changed, otherwise you would be using the same dbf, whatever directory is the default. It's unnecessary to change the default dir though.
>>Placing the following code in form.de.beforeopentables would set the correct DBC and free table paths + w/o changing default dir.
>>
>>
>>* cNewDBC and cNewFreePath are public vars
>>* Changes database and free table paths at runtime
>>nMembers = amembers(aCursors,this,1)
>>for ix = 1 to nMembers
>> if aCursors[ix,2] = "Object" and this.&aCursors[ix,1]..baseclass = "Cursor"
>> if !empty(this.&aCursors[ix,1]..database)
>> this.&aCursors[ix,1]..database = cNewDBC
>> else
>> oldCursor = this.&aCursors[ix,1]..cursorsource
>> newCursor = cNewFreePath + ;
>> iif(right(cNewFreePath,1) = "\","",;
>> iif(empty(cNewFreePath),"","\"))+;
>> substr(oldcursor,rat("\",oldCursor)+1)
>> this.&aCursors[ix,1]..cursorsource = newCursor
>> endif
>> endif
>>endfor
>>
>>But of course in the case of Chris, I would suggest still using only one dbc and tables of it, with one extra field "Company" added and filter set as needed.
>>Cetin
Hi Joe,
You could use name expressions as you did to open a database. But just opening it wouldn't use the tables contained in it. If the form already has a DBC set in DE then tables would be opened from that database. I mean you have set your form with c:\mydir\mydbc, then use "open database c:\mydir\data1\mydbc" (in beforeopentables or somewhere before the tables are opened), DE cursors would use c:\mydir\mydbc.
Cetin