General information
Category:
Forms & Form designer
>Arg... I have been struggling with this one for a few days in VFP3. I am trying to reset the path to the database for each cursor in a form's dataenvironment. At design time the cursors point to the test database. In the BeforeOpenTables method I tried the following code
>
>this.cursor1.database = gcAppPath+"\database\library.dbc"
>this.cursor2.database = gcAppPath+"\database\library.dbc"
>this.cursor3.database = gcAppPath+"\database\library.dbc"
>this.cursor4.database = gcAppPath+"\database\library.dbc"
>
>I get the following error "Error Loading form or the data environment - record number 9. File access is denied".
>
>Sometimes I will also get "Table 'foo.dbf' is not marked as belonging to the database. Would you like to create the back link to mark it?"
>
>Is this how other people reset the path to the database? Am I getting the error because the form is corrupt? Record 9 of the SCX table is the record that holds the form class.
>
>gcAppPath is a global variable and correctly gets the path using sys(2003)
Hi Evan,
I have this procedure called from the Load event (I don't like beforeopentables and set autoopen to .F.). My app.fileinit object gets the file locations from a .dbf but simply returns a full path.
So it seems your code should work. Does your gcAppPath have a final "\" perhaps?
Procedure SetCursorPaths
* Resets the paths in a DE to that spec'd by fileinit
* designed to be called from BeforeOpenTables() of DE or Load event of form
lparameter oDe && the dataenvironment object
local nn, cS, oC
local array a_O[1]
nn= amembers(a_O, m.oDe, 2)
for each cName in a_O
oC= evaluate("m.Ode." + m.cName)
if oC.BaseClass = "Cursor"
* Is the alias in fileInit?
if empty(oC.Database)
* If a free table adjust the cursorsource
oC.CursorSource= app.fileinit.fileName(oC.alias)
else
* otherwise adjust the database source
oC.Database= app.fileinit.fileName(oC.alias, .T.)
endif
endif
endfor
BTW this code was originally based on some of Jim Booth's or Doug Hennigs work - I forget which - but it was in Foxtalk away back.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only