Subject Re: FIELD DISPLAY
From Mervyn Bick <invalid@invalid.invalid>
Date Fri, 14 Jul 2017 22:57:58 +0200
Newsgroups dbase.getting-started
Attachment(s) test_sex_name.wfm

On 2017-07-14 9:52 PM, Mustansir Ghor wrote:
> 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.


There was no rowset.save() in the example because it was only showing
the use of lookupSQL.  If you append or edit records then you should
automatically include a rowset.save() in your code.

Yes, you can use a combobox.  I have revised the example to include this.

You will see that the combobox has a field assigned to its dataLink
property and an array assigned to its dataSource property.

It is normally not necessary to assign an array to the dataSource
property where the dataLink property is assigned to field which uses
lookupSQL as dBASE will create  the dropdown list automatically.  In
this case, if the two element array is not assigned to the dataSource
property, the dropdown list would show two Male entries and two Female
entries.  This is because the lookup table has entries for upper and
lower case entries in the SEX field.  Comment out the dataSource
assignment i the constructor code to see the difference.

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-14
//
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.5455
      left = 40.8571
      top = 4.8636
      width = 74.0
      text = ""
   endwith

   this.TEST_SEX_NAME1 = new QUERY(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.TEST_SEX_NAME2 = new QUERY(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.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.test_sex_name1.rowset
      allowEditing = false
      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.GRID2 = new GRID(this)
   with (this.GRID2)
      dataLink = form.test_sex_name2.rowset
      allowEditing = false
      height = 6.5
      left = 3.0
      top = 10.5
      width = 66.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.PUSHBUTTON1 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON1)
      onClick = class::PUSHBUTTON1_ONCLICK
      height = 1.0909
      left = 8.0
      top = 20.5
      width = 15.2857
      text = "Append"
   endwith

   this.PUSHBUTTON2 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON2)
      onClick = class::PUSHBUTTON2_ONCLICK
      height = 1.0909
      left = 50.0
      top = 20.5
      width = 15.2857
      text = "Save"
   endwith

   this.COMBOBOX1 = new COMBOBOX(this)
   with (this.COMBOBOX1)
      dataLink = form.test_sex_name2.rowset.fields["sex"]
      height = 1.0
      left = 45.0
      top = 18.5
      width = 12.0
      dataSource = 'array {"Male","Female"}'
      style = 1        // DropDown
   endwith

   this.rowset = this.test_sex_name1.rowset

   function PUSHBUTTON1_onClick()
      form.test_sex_name2.rowset.beginAppend()
                form.entryfield1.setfocus()
      return

   function PUSHBUTTON2_onClick()
           form.test_sex_name2.rowset.save()
      form.test_sex_name1.requery()
      return

endclass