Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parametizing Dataenvironment?
Message
De
25/09/1997 09:18:33
 
 
À
24/09/1997 19:49:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00049913
Message ID:
00051577
Vues:
43
>>>Hello all,
>>>New to VFP - still struggling with the basics.
>>>
>>>I have a simple table maintenance form - a code and a description. Rather than create 15 practically identical forms for the 15 tables, I want to pass the name of the table as a parameter to a single generic form 'TableMaint' and load the table at runtime. (I also pass the form's caption).
>>>
>>>In TableMaint.init I have -
>>> THISFORM.tablename = lcTableName && parameter passed from menu
>>> THISFORM.grid1.recordsource=lcTableName
>>>
>>>In DataEnvironment.init -
>>> THIS.InitialSelectAlias = THISFORM.TableName
>>>
>>>In DataEnvironment.OpenTables
>>> DataEnvrionment::OpenTables
>>> USE (THISFORM.TableName)
>>>
>>>DataEnvironment.autoopen=.F.
>>>DataEnvironment.autoclose=.F.
>>>
>>>The form appears, the caption is set, but no table is loaded. It looks to me as if the DataEnvironment's init method executes before the form's so the tablename property hasn't been initialized yet.
>>>Should I set a global variable to the table's name before running the form? But I want to be able to run multiple instances of the form.
>>>What to do? All suggestions welcomed.
>>>
>>>Martin
>>
>>If DE.AutoOpenTables=.f., you will never fire OpenTables you do it explicitly in code. There are meny ways to handle your situation. One of them is not to fight with DE, open all 15 tables, and in Form.Init event select appropriate table:
>>**** Form.Init event
>>Parameter cTablename
>>Select (cTablename)
>
>
>>>I have a simple table maintenance form - a code and a description. Rather than create 15 practically identical forms for the 15 tables, I want to pass the name of the table as a parameter to a single generic form 'TableMaint' and load the table at runtime. (I also pass the form's caption).
>>>
>>>The form appears, the caption is set, but no table is loaded. It looks to me as if the DataEnvironment's init method executes before the form's so the tablename property hasn't been initialized yet.
>>>Should I set a global variable to the table's name before running the form? But I want to be able to run multiple instances of the form.
>>
>>If DE.AutoOpenTables=.f., you will never fire OpenTables you do it explicitly in code. There are meny ways to handle your situation. One of them is not to fight with DE, open all 15 tables, and in Form.Init event select appropriate table:
>>**** Form.Init event
>>Parameter cTablename
>>Select (cTablename)
>
>
>Just came back to this - still having problems with it!
>I wasn't too clear on what you meant - should I have DE.AutoOpenTables=.f if I'm going to specify which table to select?
>
>I tried your suggestion, but found that by the time I get to Form Init event, the controlsource's have already been assigned to the fields
>of the first table/view in the dataenvironment.
>Maybe I should assign the controlsource property of each control on the form/grid to the fields in cTablename? If so, can you tell me how I reference those fieldnames?
>
>Sorry to bother you with newbie questions but I'm getting nowhere with this;)
>
>Martyn

Firstly, DE.AutoOpenTables=.t.
Then all ControlSources (RecordSource for grids) should be empty in design mode
>>**** Form.Init event
>>Parameter cTablename
>>Select (cTablename)
*** now you fill controls, e.g.
Thisform.Grid1.RecordSource=cTablename
Thisform.Text1.Value=&cTablename..description

This is not the only method you can use, but it's workable.
Edward Pikman
Independent Consultant
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform