Microsoft KB Archive/229779

= PRB: Data Environment Stores Paths as Relative Paths =

Article ID: 229779

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q229779



SYMPTOMS
If you develop a form with one or more tables in the data environment and the table in the data environment is on the same drive as the Visual FoxPro form, when the form is deployed to computers, the data environment looks on the local drive for the table, resulting in the following error:

Error instantiating cursor object. Could not find (table file name).



CAUSE
The data environment stores the path to the table as a relative path. For example, if a table used in the data environment is located in "F:\MyData" and the form is located in "F:\MyData\Forms," Visual FoxPro stores the path as "..\MyTable.Dbf" instead of storing the path as "F:\MyData\MyTable.Dbf." When a relative path is stored, Visual FoxPro looks for the table on the drive that the form is run from.



RESOLUTION
There are two possible resolutions for this problem.  The first is to manually edit the SCX file. To do this, use the following steps:  Use the SCX file as a table, making sure to include the SCX extension. For instance, USE MyForm.Scx. Browse the SCX file. Double-click on the Class memo field and position the memo field window and the browse window so that both are visible. Scroll through the records in the browse window until the memo field window displays "cursor" (without the quotation marks). In the Properties memo field window, edit the CursorSource property so that it has the full path, not a relative path. For instance, "d:\MyDirectory\Data\MyTable.dbf" instead of "..\MyTable.Dbf." The CursorSource property can be entered with or without quotation marks. However, if the path contains spaces, quotation marks are required. Double-click the Properties memo field in the browse window.</li></ol> </li> A second resolution is to create the form on a different drive than the one on which the tables are stored. Visual FoxPro stores the complete path in the data environment.</li></ol>

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol>  Type the following code into the Command window: MD C:\DE_TEST CD C:\DE_TEST CREATE TABLE DE_TEST (ID C(10)) MD C:\DE_TEST\FORMS CD C:\DE_TEST\FORMS MODIFY FORM DE_TEST </li> When the form opens, right-click on the form and select Data Environment. In the Add Table or View dialog box, click Other. In the Open dialog box, find and double-click the table C:\DE_TEST\DE_TEST.DBF.</li> Save the form and close it.</li>  Move the form to a directory on a drive other than C:. For example, move the form to d:\de_test. Run the form by typing the following command in the Command window: DO FORM D:\de_test\de_test Note that the following error message is displayed:

Error instantiating cursor object. Could not find (table file name).

</li></ol>

<div class="references_section">