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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP6 - finding table used in form 1

Status
Not open for further replies.

wetton

Technical User
Jun 26, 2006
42
AU
I have generated a form using the wizard based on a single table.

I have the table at \ApplicationData\Username\Myapp.

In development I am able to set default to this directory on my PC - set the Data Environment with the table in that folder and all works well.

Now in a distributed exe I won't know where that \ApplicationData\Username\Myapp folder is.


How do I set the Data Environment of the form to reflect this variable reference?

Many thanks

PW

 
Brian,

Thanks for your reply

I have put a SET PATH TO (mydatapath) in the line before I call the form. Unfortunatey the form still does not find the table.

In hunting for a solution I have come across a thread in


However this refers to VFP 5.0 and I don't know how to do some of the things mentioned there.

I quote

'We overcame this by putting a custom method in our Form baseclass, UpdateDataLocation.

PW I have done this

----------
This method takes a DataEnvironment as a parameter.

PW I am not certain about this bit I have put

PARAMETERS (mydatapath)
in the method
------
If then remembers the DataEnvironment.

if the cursor Database property is not empty its path is changed the one we want (some property or variable somewhere).


If Database is emtpy it is a free table and the CursorSource is changed.

In everyform you are using a DE for add

THISFORM.UpdateDataLocation( THIS)
RETURN DODEFAULT()

to the BeforeOpenTables Event.

I don't see this event - I have tried the Load event but I still get the error.

Any more clues?

PW
 

PW,

I think you're making this more complicated than it needs be.

Forget about custom methods, cursor properties and \ApplicationData\Username\Myapp. All you need to know is where the table is stored on the user's system. How you find that is up to you. You could ask the user to navigate to it, or you could store the location in an INI file, the Registry or just a plain text file.

Once you know the name of the directory where the table is stored, just add that directory to your search path:

SET PATH TO SomeFolder ADDITIVE

If your version of VFP doesn't support the ADDITIVE keyword, it is slightly more complicated:

lcPath = SET("PATH") + "," + SomeFolder
SET PATH TO &lcPath

When VFP tries to open the table, it will first look in \ApplicationData\Username\Myapp (i.e the folder as specified in your development environment). That folder won't be present on the user's system, so it will look along the search path and find the table.

This is the correct approach. If it doesn't work, it's because you have done something wrong. It's better to figure out what you did wrong before you start looking at more complicated solutions.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike,

Once again you have pulled me out of a puzzling hole...


PW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top