Subject Re: how to link a entryfield when using brows
From Mervyn Bick <invalid@invalid.invalid>
Date Wed, 2 Mar 2022 09:49:45 +0200
Newsgroups dbase.getting-started
Attachment(s) browser.wfmbrowser1.wfm

On 2022/03/02 06:31, Ken Mayer wrote:

> I don't think you can. Weird. I did some experimenting and can't find a
> way to do that. You *really* need to learn the modern way of working
> with dBASE. Drag a table to the form from the Navigator, and work from
> there (or for more complex forms, use a data module) ...

I depends on what Agostinho wants to do.

If he wants to show the value of each field of the selected record in a
separate entryfield then yes.  Example attached.

If he wants to show just the value in the field he's clicked on in the
browser in a single entryfield then no, it can't be done using XDML.
This is, however, quite straightforward using OODML.  Example attached.

Mervyn.


** END HEADER -- do not remove this line
//
// Generated on 2022-03-02
//
parameter bModal
local f
f = new browserForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class browserForm of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      onClose = class::FORM_ONCLOSE
      height = 18.0455
      left = 31.1429
      top = 0.5909
      width = 145.4286
      text = ""
      view = ":DBASESAMPLES:fish.dbf"
   endwith

   this.BROWSE1 = new BROWSE(this)
   with (this.BROWSE1)
      onLeftMouseUp = class::BROWSE1_ONLEFTMOUSEUP
      height = 10.5909
      left = 7.8571
      top = 2.7727
      width = 121.0
      alias = "FISH"
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      height = 1.0
      left = 27.7143
      top = 15.0909
      width = 41.1429
      value = "Entryfield1"
   endwith

   this.ENTRYFIELD2 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD2)
      height = 1.0
      left = 71.1429
      top = 15.0909
      width = 52.8571
      value = "Entryfield2"
   endwith

   this.ENTRYFIELD3 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD3)
      height = 1.0
      left = 13.0
      top = 15.0909
      width = 9.2857
      value = "Entryfield3"
   endwith


   function BROWSE1_onLeftMouseUp(flags, col, row)
      form.entryfield1.value = name
      form.entryfield2.value = species
      form.entryfield3.value = id
      return


   function form_onClose()
      use
      return

   function form_onOpen()
      form.entryfield1.value = name
      form.entryfield2.value = species
      form.entryfield3.value = id
      return

endclass



** END HEADER -- do not remove this line
//
// Generated on 2022-03-02
//
parameter bModal
local f
f = new browser1Form()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class browser1Form of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 16.0
      left = 35.1429
      top = 1.6364
      width = 127.4286
      text = ""
   endwith

   this.DBASESAMPLES1 = new DATABASE(this)
   with (this.DBASESAMPLES1)
      left = 15.0
      top = 1.0
      width = 11.0
      height = 1.0
      databaseName = "DBASESAMPLES"
      active = true
   endwith

   this.FISH1 = new QUERY(this)
   with (this.FISH1)
      left = 16.0
      top = 1.0
      width = 3.0
      height = 1.0
      database = form.dbasesamples1
      sql = "select * from FISH.DBF"
      active = true
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      onLeftMouseUp = class::GRID1_ONLEFTMOUSEUP
      dataLink = form.fish1.rowset
      columns["COLUMN1"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN1"])
         dataLink = form.fish1.rowset.fields["id"]
         editorType = 1        // EntryField
         width = 15.7143
      endwith
      columns["COLUMN2"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN2"])
         dataLink = form.fish1.rowset.fields["name"]
         editorType = 1        // EntryField
         width = 42.8571
      endwith
      columns["COLUMN3"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN3"])
         dataLink = form.fish1.rowset.fields["species"]
         editorType = 1        // EntryField
         width = 57.1429
      endwith
      columns["COLUMN4"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN4"])
         dataLink = form.fish1.rowset.fields["length cm"]
         editorType = 3        // SpinBox
         width = 14.2857
      endwith
      columns["COLUMN5"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN5"])
         dataLink = form.fish1.rowset.fields["description"]
         editorType = 5        // Editor
         width = 28.5714
      endwith
      with (columns["COLUMN1"].headingControl)
         value = "ID"
      endwith

      with (columns["COLUMN2"].headingControl)
         value = "Name"
      endwith

      with (columns["COLUMN3"].headingControl)
         value = "Species"
      endwith

      with (columns["COLUMN4"].editorControl)
         rangeMax = 100
         rangeMin = 1
      endwith

      with (columns["COLUMN4"].headingControl)
         value = "Length CM"
      endwith

      with (columns["COLUMN5"].headingControl)
         value = "Description"
      endwith

      height = 8.0909
      left = 6.4286
      top = 4.0909
      width = 114.2857
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      height = 1.0
      left = 40.7143
      top = 13.0909
      width = 49.7143
      value = "Entryfield1"
   endwith

   this.TEXTLABEL1 = new TEXTLABEL(this)
   with (this.TEXTLABEL1)
      height = 1.0
      left = 27.8571
      top = 13.2727
      width = 12.0
      text = "Textlabel1"
   endwith

   this.rowset = this.fish1.rowset

   function GRID1_onLeftMouseUp(flags, col, row)
      cmd = 'form.entryfield1.value =  form.grid1.columns["column'+form.grid1.currentcolumn+'"].datalink.value'
      &cmd
      cmd = 'form.textlabel1.text =  form.grid1.columns["column'+form.grid1.currentcolumn+'"].headingcontrol.value'
      &cmd
      return

   function form_onOpen()
      cmd = 'form.entryfield1.value =  form.grid1.columns["column'+form.grid1.currentcolumn+'"].datalink.value'
      &cmd
      cmd = 'form.textlabel1.text =  form.grid1.columns["column'+form.grid1.currentcolumn+'"].headingcontrol.value'
      &cmd
      return

endclass