Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jerzy Kopinski
  Where is Jerzy Kopinski?
 Pruszcz Gdanski
 Poland
 Jerzy Kopinski
 To: Tom Thomas
  
 
 
 Tom Thomas
 Tags
Subject: RE: Data Environment
Thread ID: 47725 Message ID: 79633 # Views: 2 # Ratings: 0
Version: Visual FoxPro 6 Category: Forms
Date: Thursday, October 20, 2005 9:14:50 AM         
   


> Can we add tables to the Form-Data Environment using Code instead of selecting it offline from Form Data Environment window ?
> If so, how ?
> And in which Form event the code should be entered ?
> Can we add tables to the Dataenvironment dynamically even after the form events like load, init and activate are over ?
> Once the tables are added to the Data Environment with code, will the tables be automatically closed when the form is released ?
>
> Thanks in advance.
> Tom
>



Hi Tom,

You can define DataEnvironment of any form using OOP properties of VFP. In BeforeOpenTables method of DataEnvironment try to add all cursors and define its properties.

this.AddObject("cursor1","cursor")
this.AddObject("cursor2","cursor")
....
this.cursor1.alias='alias1'
this.cursor1.cursorsource='table1'
this.cursor1.database='C:\...\DTB1.DBC'
.....


Sometimes I redefine DE of forms in runtime, but usually to simplify the code I have to write, I add cursors defining DE of forms (it can be the same table) and then in the BeforeOpenTables method change only aliases, cursorsources and database.

Jerzy Kopinski

ENTIRE THREAD

Data Environment Posted by Tom Thomas @ 7/27/2004 11:00:59 AM
RE: Data Environment Posted by Boudewijn Lutgerink @ 7/27/2004 11:45:05 AM
RE: Data Environment Posted by Tom Thomas @ 7/27/2004 12:08:51 PM
RE: Data Environment Posted by Andy Kramek @ 7/27/2004 1:01:11 PM
RE: Data Environment Posted by Tom Thomas @ 7/27/2004 2:35:51 PM
RE: Data Environment Posted by Andy Kramek @ 7/27/2004 3:51:56 PM
RE: Data Environment Posted by Kent Jensen @ 10/20/2005 8:00:55 AM
RE: Data Environment Posted by Andy Kramek @ 10/20/2005 1:28:07 PM
RE: Data Environment Posted by Kent Jensen @ 11/2/2005 5:56:47 AM
RE: Data Environment Posted by Boudewijn Lutgerink @ 11/2/2005 7:18:44 AM
RE: Data Environment Posted by Victor @ 11/2/2005 4:22:03 PM
RE: Data Environment Posted by Ken Murphy @ 11/2/2005 6:03:11 PM
RE: Data Environment Posted by Kent Jensen @ 11/4/2005 4:00:02 AM
RE: Data Environment Posted by Boudewijn Lutgerink @ 11/4/2005 6:07:02 AM
RE: Data Environment Posted by Kent Jensen @ 11/4/2005 4:03:13 AM
RE: Data Environment Posted by Ken Murphy @ 10/20/2005 3:28:45 PM
RE: Data Environment Posted by Jerzy Kopinski @ 10/20/2005 9:14:50 AM
RE: Data Environment Posted by Terry Bottorff @ 10/21/2005 5:55:03 PM
RE: Data Environment Posted by Jerzy Kopinski @ 10/24/2005 7:25:36 AM