Subject Re: FIELD DISPLAY
From Mustansir Ghor <mustan31@hotmail.com>
Date Fri, 14 Jul 2017 15:52:44 -0400
Newsgroups dbase.getting-started

Dear Mervyn

In the program I did not find anywhere rowset.save(). By virtue of Datalink be it for Entryfield or Grid, does it save the record. Suppose entryfield for sex would have been Combobox. Would it be better as user would have option of choosing.

Regards
Mustansir

Mervyn Bick Wrote:

> On 2017-07-13 10:17 AM, Mustansir Ghor wrote:
> > Dear All
> >
> > I have a logical field SEX which is displaying as entryfield shown below
> >
> >   this.ENTRYFIELDSEX1 = new ENTRYFIELD(this)
> >     with (this.ENTRYFIELDSEX1)
> >        dataLink = form.labres1.rowset.fields["sex"]
> >        height = 0.2292
> >        left = 0.7292
> >        top = 1.6042
> >        width = 0.2188
> >     endwith
> >
> > How can I modify this to display MALE or FEMALE
>
> Create a little lookup table and then set the field's lookupSQL property.
>
> A small example is attached.
>
> Mervyn.
>
> if file('sex_name.dbf')
>   // drop table sex_name
> endif
>
> if not file('sex_name.dbf')
>    create table sex_name  (sex character(1),sex_name character(6))
>
>    insert into sex_name  (sex,sex_name) values ("M","Male")
>    insert into sex_name  (sex,sex_name) values ("m","Male")
>    insert into sex_name  (sex,sex_name) values ("F","Female")
>    insert into sex_name  (sex,sex_name) values ("f","Female")
> endif
>
> if file('test_sex_name.dbf')
>   // drop table test_sex_name
> endif
>
> if not file('test_sex_name.dbf')
>    create table test_sex_name  (id autoinc,name character(15),sex character(1))
>
>    insert into test_sex_name  (name,sex) values ("Arthur","M")
>    insert into test_sex_name  (name,sex) values ("Albert","m")
>    insert into test_sex_name  (name,sex) values ("Anne","F")
>    insert into test_sex_name  (name,sex) values ("Angela","f")
> endif
>
>
> ** END HEADER -- do not remove this line
> //
> // Generated on 2017-07-13
> //
> parameter bModal
> local f
> f = new test_sex_nameForm()
> if (bModal)
>    f.mdi = false // ensure not MDI
>    f.readModal()
> else
>    f.open()
> endif
>
> class test_sex_nameForm of FORM
>    with (this)
>       height = 22.1818
>       left = 65.2857
>       top = 13.3182
>       width = 65.0
>       text = ""
>    endwith
>
>    this.TEST_SEX_NAME2 = new QUERY()
>    this.TEST_SEX_NAME2.parent = this
>    with (this.TEST_SEX_NAME2)
>       left = 48.0
>       width = 11.0
>       height = 1.0
>       sql = 'select * from "test_sex_name.DBF"'
>       active = true
>    endwith
>
>    with (this.TEST_SEX_NAME2.rowset)
>       with (fields["sex"])
>          lookupSQL = "select * from sex_name"
>       endwith
>    endwith
>
>    this.TEST_SEX_NAME1 = new QUERY()
>    this.TEST_SEX_NAME1.parent = this
>    with (this.TEST_SEX_NAME1)
>       left = 36.0
>       width = 11.0
>       height = 1.0
>       sql = 'select * from "test_sex_name.DBF"'
>       active = true
>    endwith
>
>    this.GRID1 = new GRID(this)
>    with (this.GRID1)
>       dataLink = form.test_sex_name1.rowset
>       height = 6.5
>       left = 3.0
>       top = 1.5
>       width = 56.0
>    endwith
>
>    this.ENTRYFIELD1 = new ENTRYFIELD(this)
>    with (this.ENTRYFIELD1)
>       dataLink = form.test_sex_name2.rowset.fields["name"]
>       height = 1.0
>       left = 20.0
>       top = 18.5
>       width = 8.0
>    endwith
>
>    this.ENTRYFIELD2 = new ENTRYFIELD(this)
>    with (this.ENTRYFIELD2)
>       dataLink = form.test_sex_name2.rowset.fields["sex"]
>       height = 1.0
>       left = 42.0
>       top = 18.5
>       width = 8.0
>    endwith
>
>    this.GRID2 = new GRID(this)
>    with (this.GRID2)
>       dataLink = form.test_sex_name2.rowset
>       height = 6.5
>       left = 3.0
>       top = 10.5
>       width = 56.0
>    endwith
>
>    this.TEXTLABEL1 = new TEXTLABEL(this)
>    with (this.TEXTLABEL1)
>       height = 1.0
>       left = 3.0
>       top = 0.5
>       width = 12.0
>       text = "Raw data"
>    endwith
>
>    this.TEXTLABEL2 = new TEXTLABEL(this)
>    with (this.TEXTLABEL2)
>       height = 1.0
>       left = 3.0
>       top = 9.5
>       width = 19.0
>       text = "Data with lookupSQL"
>    endwith
>
>    this.rowset = this.test_sex_name1.rowset
>
> endclass
>