Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking dataenvironment paths before form opens

Status
Not open for further replies.

kindred

Programmer
Feb 28, 2001
50
US
I'm trying to figure out how to check the paths of the tables/views in my form's dataenvironment to see if their paths exist. Unfortunately I can't seem to do this without the form opening and executing other events. I'm trying to do this within the program file I use to execute and launch the form from.

For example...

If File(Form1.DataEnvironment1.Cursor1.Database) = .F.
Form1.DataEnvironment1.Cursor1.Database = MMyNewPath
EndIf

Thanks in advanced,
Stephen Hardie


P.S. Please foward your anwser to shardie@kpcorp.com


 
Hi Stephen,

Few suggestions:

1. Put your code in the BeforeOpenTables event of the dataenvironment.Example:

Code:
PROCEDURE DataEnvironment.BeforeOpenTables
  If ! File(This.Cursor1.CursorSource)
    This.Cursor1.CursorSource = MMyNewPath
  EndIf
ENDPROC

2. Learn to use the SET PATH command. When the dataenvironment doesnt find the table at the location specified by the cursor's cursorsource property, it will be able to find it on the path. For Example:

Code:
lcPath=SET('PATH')+';'+MMyNewPath
SET PATH TO (lcPath)

Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Jon,

Thanks for the help, I'll try what you just mentioned. I also soon figured out the BeforeOpenTables Event a little while after posting it.

I'm still a little unclear how the Dataenvironment (DE) knows when to check other places for the database.

Say my cursor1 is set to C:\MyApp\Data\data1.dbc in the DE.
And I set paths to the SET PATH cmd as well...
SET PATH C:\MyApp\;\\MyServer\Share\MyApp
If the path to C:\MyApp\Data\ no longer exists, it will check \\MyServer\Share\MyApp\ instead for the data1.dbc?

I find with Microsoft help files, they tend not to give enough detail to what is possible with a command, such as SET PATH.


Thanks,
Stephen Hardie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top