Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing Data Environment Tables From Multiple Forms
Message
 
 
To
05/11/2000 13:48:30
Carmen Gassi
Perseus Software Systems
Oakville, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00438122
Message ID:
00438189
Views:
10
>Larry
> Thanks for the suggestions. The scenario you described was correct. I was launching subsequent forms from an initial form. I changed the data session status as you suggested, and after I modified all subsequent forms to use default data session, I was able to access the tables from all the forms. Thank you for your suggestion and time.
>
>Carmen

Hi Carmen,

This is very useful trick. I believe I firstly learned it from John Koziol (it was more than year ago, so I'm not quite sure about the source of this info) and I was going to suggest it too. I use this trick in all dependant forms...

Very simple and works great.

>
>>>I have created an application that consists of about 5 forms. I am trying to use the data environment to open the tables in the first form and have them available to all the forms. I have set the data environment properties Autoopen tables to .t. and the autoclose tables to .f., but when I activate the successive forms, they cannot see the tables. It seems that I have to set a separate data environment for each form. This doesn't make a lot of sense to me, but then again, I am somewhat new to forms and data environment handling. Any ideas would be appreciated.
>>>
>>>Carmen Gassi
>>
>>It sounds like you have separate (private) datasessions for each form. Three scenarios come to mind.
>>
>>1. You are launching your forms independently of one another from a menu.
>>
>>2. You launch form 1 from a menu and then the subsequent forms are launched from form 1 via some mechanism.
>>
>>3. A combination of scenario 1 and 2.
>>
>>Let's take the easiest first, scenario 2. Set the datasession property of form 1 to 2 - Private Datasession and set the datasession property of the other forms to 1 - Default Datasession. This will cause the "child" forms to not create datasessions of their own and to take part in the datasession where they were launched.
>>
>>Scenario 1 can be handled in a couple of ways. You could set the datasession property of all your forms to 1 - Default Datasession. Then all forms would particaipate in datasession 1 (the VFP/Screen datasession). Or you could configure your "child" forms to issue a SET DATASESSION TO in the Load event. The datasession would be the datasessionID proprety of the first form. You may be able to get this from the _Screen.ActiveForm.DatasessionID property.
>>
>>NOTE - The changing of the datasession needs to take place in the Load before any controls are instantiated. If you wait until the Init, bound controls will not have the datasource available to them.
>>
>>Depending on what approach you implement, you could use a combination of the other solutions or standardize on the one that changed datasessions.
>>
>>HTH.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform