Subject Re: VARIABLE DECLARATION
From MUSTANSIR GHOR <mustan31@hotmail.com>
Date Tue, 17 Apr 2018 12:50:18 -0400
Newsgroups dbase.getting-started

Dear Ken Sir

Thank you. I felt very nice when I saw that I was working on same lines.

However I had to add following statement  in the event handle of radio button change event.
form.cbitem.datasource=form.qprices.rowset.fields["name"]

regards
mustansir





Ken Mayer Wrote:

> On 4/16/2018 12:48 PM, MUSTANSIR GHOR wrote:
> > Sorry for the 2nd OR here refers to radio button event handler. Also the last line I forgot to write word end , after the vanish
>
>
> If I understand what you're trying, copy the attacked out to a .wfm
> file, save it, run it. It will create five tables that are identical in
> format with the name of the table in a field. There is a datalinked
> entryfield that shows the value of "TableName" ... when you change
> radiobuttons, the query's SQL property is changed and the value in the
> entryfield updates for the current record. Examine the code, it should
> be pretty easy to read.
>
> Ken
>
> --
> *Ken Mayer*
> Ken's dBASE Page: http://www.goldenstag.net/dbase
> The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
> dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
> dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
>
> // setup -- drop existing tables:
> close database
> if _app.databases[1].tableExists( "Table 1" )
>    _app.databases[1].dropTable( "Table 1" )
> endif
> if _app.databases[1].tableExists( "Table 2" )
>    _app.databases[1].dropTable( "Table 2" )
> endif
> if _app.databases[1].tableExists( "Table 3" )
>    _app.databases[1].dropTable( "Table 3" )
> endif
> if _app.databases[1].tableExists( "Table 4" )
>    _app.databases[1].dropTable( "Table 4" )
> endif
> if _app.databases[1].tableExists( "Table 5" )
>    _app.databases[1].dropTable( "Table 5" )
> endif
>
> // create tables:
> create table "table 1" ( TableName char(10), TestData char(10) )
> create table "table 2" ( TableName char(10), TestData char(10) )
> create table "table 3" ( TableName char(10), TestData char(10) )
> create table "table 4" ( TableName char(10), TestData char(10) )
> create table "table 5" ( TableName char(10), TestData char(10) )
>
> // quickly add a single row to each table and set the data:
> use "table 1"
> append blank
> replace TableName with "Table 1", TestData with "Test Data"
> use "table 2"
> append blank
> replace TableName with "Table 2", TestData with "More Data"
> use "table 3"
> append blank
> replace TableName with "Table 3", TestData with "Data data"
> use "table 4"
> append blank
> replace TableName with "Table 4", TestData with "More more"
> use "table 5"
> append blank
> replace TableName with "Table 5", TestData with "Data 5555"
> // close tables:
> use
>
> clear // output pane of command window
>
>
> ** END HEADER -- do not remove this line
> //
> // Generated on 04/16/2018
> //
> parameter bModal
> local f
> f = new MustansirExampleForm()
> if (bModal)
>    f.mdi = false // ensure not MDI
>    f.readModal()
> else
>    f.open()
> endif
>
> class MustansirExampleForm of FORM
>    with (this)
>       metric = 6        // Pixels
>       height = 218.0
>       left = 386.0
>       top = 257.0
>       width = 327.0
>       text = "Mustansir Example"
>    endwith
>
>    this.TABLE11 = new QUERY(this)
>    with (this.TABLE11)
>       left = 231.0
>       top = 158.0
>       width = 38.0
>       height = 37.0
>       sql = 'select * from "Table 1.dbf"'
>       active = true
>    endwith
>
>    this.RECTANGLE1 = new RECTANGLE(this)
>    with (this.RECTANGLE1)
>       left = 10.0
>       top = 48.0
>       width = 89.0
>       height = 139.0
>       text = ""
>    endwith
>
>    this.TEXT1 = new TEXT(this)
>    with (this.TEXT1)
>       height = 24.0
>       left = 0.0
>       top = 0.0
>       width = 325.0
>       anchor = 2        // Top
>       alignVertical = 1        // Middle
>       alignHorizontal = 1        // Center
>       fontBold = true
>       text = "Mustansir Example"
>    endwith
>
>    this.TABLE1RB = new RADIOBUTTON(this)
>    with (this.TABLE1RB)
>       onChange = class::TABLE1RB_ONCHANGE
>       height = 24.0
>       left = 22.0
>       top = 59.0
>       width = 68.0
>       text = "Table 1"
>       group = true
>       value = true
>    endwith
>
>    this.TABLE2RB = new RADIOBUTTON(this)
>    with (this.TABLE2RB)
>       onChange = class::TABLE1RB_ONCHANGE
>       height = 24.0
>       left = 22.0
>       top = 81.0
>       width = 68.0
>       text = "Table 2"
>    endwith
>
>    this.TABLE3RB = new RADIOBUTTON(this)
>    with (this.TABLE3RB)
>       onChange = class::TABLE1RB_ONCHANGE
>       height = 24.0
>       left = 22.0
>       top = 107.0
>       width = 68.0
>       text = "Table 3"
>    endwith
>
>    this.TABLE4RB = new RADIOBUTTON(this)
>    with (this.TABLE4RB)
>       onChange = class::TABLE1RB_ONCHANGE
>       height = 24.0
>       left = 22.0
>       top = 132.0
>       width = 68.0
>       text = "Table 4"
>    endwith
>
>    this.TABLE5RB = new RADIOBUTTON(this)
>    with (this.TABLE5RB)
>       onChange = class::TABLE1RB_ONCHANGE
>       height = 24.0
>       left = 22.0
>       top = 158.0
>       width = 68.0
>       text = "Table 5"
>    endwith
>
>    this.ENTRYFIELD1 = new ENTRYFIELD(this)
>    with (this.ENTRYFIELD1)
>       when = {; return false}
>       dataLink = form.table11.rowset.fields["tablename"]
>       height = 22.0
>       left = 125.0
>       top = 120.0
>       width = 135.0
>    endwith
>
>    this.TEXT2 = new TEXT(this)
>    with (this.TEXT2)
>       height = 66.0
>       left = 129.0
>       top = 50.0
>       width = 153.0
>       text = "DataLinked to Field TableName in one of tables referenced by radiobuttons:"
>    endwith
>
>    this.rowset = this.table11.rowset
>
>    function TABLE1RB_onChange()
>       if( this.value ) // as more than one RB will fire for each change,
>                        // only execute code for the one that is now "true"
>          cTable = this.text
>          form.Table11.sql := "select * from '"+cTable+"'"
>       endif
>    return
>
> endclass
>