Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change data path after compile form
Message
From
11/01/2001 02:42:00
 
 
To
11/01/2001 01:24:25
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00462065
Message ID:
00462088
Views:
13
>I design my form using dataenvironment. After I compile it in my application I change my data path (of course I have a path to new directory) but my form doen'nt work.

You can make this code reusable if you have a global variable or Application property that holds your data directory.

First turn AutoOpenTables in your DE to .F.

Add this code like this to the Load() event of your form (you could put this in a class so you don't need to remember to put it in every form):
LOCAL lnCnt, loObj, lcDBC, lcNewDataPath

lcNewDataPath = ***A property or somethign with your Datapath in it

LOCAL ARRAY laList[1]

*** Get Object Members of DE
=AMEMBERS(laList, THISFORM.DATAENVIRONMENT, 2)
IF EMPTY(laList[1])
	*** Nothing in DE
	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)
				*** Contained Table
				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
				*** Free Table
				lcDBC = SUBSTR( loObj.CursorSouce, RAT('\',loObj.CursorSouce))
				loObj.CursorSouce = tcNewDataPath + lcDBC
			ENDIF
		ENDIF
	NEXT
ENDIF

* Now open the tables
Thisform.DataEnvironment.OpenTables()
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform