>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)
Edward Pikman
Independent Consultant