>I have a situation where the pathing of the production copy of some data is different than it is on my local machine. I normally don't have to deal with this since my apps run from any folder a user wants to place it, but the DATA folder is usually a subfolder and all the tables and the DBC reside there (they can change this, but no one ever does). In this situation, the tables are on one drive and the DBC is on another (they are on the same physical server, perhaps even the same physical drive, but the data is on mapped drive J: and the DBC is on mapped drive W:). So when I copy this DBC and the tables over to my computer and try to open a table, it tells me it can't find the database and shows the path as J:yada,yada,yada (you never knew Jerry Seinfeld was one of the VFP developers, did you?).
>
>How do I get this table open? I'm probably forgetting something obvious - it's been that kind of day - but I was thinking it wouldn't look for the exact path if the DBC was open and your referenced it, as in DBCName!TableName. No dice. Or if the DBC was set as the current DBC. No dice there, either. What gives?
I allow the database to be set based on user preferences and also to allow for different drive mapping letters if in a network. In the form.dataenvironment.BeforeTablesOpen(), I call the following:
FUNCTION SetDBCPath
LPARAMETERS poFormDE,pcDBCPath,pcDBCName
LOCAL lcDBCName, lcFilePath, lnNumCursors, lnNdx
lcDBCName = FORCEEXT(pcDBCName,"DBC")
lcFilePath = ADDBS(pcDBCPath) + lcDBCName
lnNumCursors = AMEMBERS(lcProperties,poFormDE,2)
FOR lnNdx=1 TO lnNumCursors
IF UPPER(LEFT(lcProperties[lnNdx],6)) = "CURSOR"
IF ATC(lcDBCName,poFormDE.&lcProperties[lnNdx]..database) > 0
poFormDE.&lcProperties[lnNdx]..database = lcFilePath
ENDIF
ENDIF
ENDFOR
ENDFUNC
This sets the new path for the database. The tables can then be opened as the path is determined from the database. I store the network config into the registry for each user and then pass this in the call to the above UDF.