>I have a project I’m working on at the office. The tables for the project are on a different computer and I’m accessing them using a Set Path To \\NT1\Public\Data. On the weekends I want to bring the project home, so I restore the tables in a local folder at home like C:\VFP\Data. I change my default path and search path in Tools/Options. I remove the tables from my data environment and from the project then add them back in. Then I change my Set Path To C:\VFP\Data. I can’t get VFP to see my new path or tables. Not only won’t it see the path, it also changes my search path back to \\NT1\Public\Data.
>Where is this coming from and how can I do this?
>
>Thanks in advance
This path information is stored in properties of cursor objects in the dataenvironment. The common way to handle this is with a routine that runs before thetables are opened, that loops through the cursors in the DE, and changes the database property depending on some current setting: a registry entry, a public variable, form property, etc. My framework has a ChangeDataPath routine that is called from the form.load that does this.
LPARA tcNewDataPath
LOCAL lnCnt, loObj, lcDBC, lcNewDataPath
IF TYPE("tcNewDataPath") <> "C"
RETURN .F.
ELSE
lcNewDataPath = tcNewDataPath
ENDIF
LOCAL ARRAY laList[1]
=AMEMBERS(laList, THISFORM.DATAENVIRONMENT, 2)
IF EMPTY(laList[1])
RETURN
ENDIF
IF ALEN( laList,1 ) > 0
FOR i = 1 TO ALEN(laList,1 )
loObj = EVAL("ThisForm.DataEnvironment."+laList[i])
IF LOWER(loObj.BASECLASS ) = 'cursor' AND "\"$loObj.DATABASE
IF !EMPTY(loObj.DATABASE)
lcDBC = SUBSTR(loObj.DATABASE, RAT('\', loObj.DATABASE))
loObj.DATABASE = tcNewDataPath + lcDBC
IF !DBUSED(loObj.Database)
OPEN DATABASE (loObj.Database)
ENDIF
SET DATABASE TO (loObj.Database)
ELSE
lcDBC = SUBSTR( loObj.CursorSouce, RAT('\',loObj.CursorSouce))
loObj.CursorSouce = tcNewDataPath + lcDBC
ENDIF
ENDIF
NEXT
ENDIF
Erik Moore
Clientelligence