Subject Re: Type mismatch ?
From Mervyn Bick <invalid@invalid.invalid>
Date Sat, 9 May 2020 10:37:28 +0200
Newsgroups dbase.getting-started
Attachment(s) test_memo_like1.wfm

On 09/05/2020 00:32, Tom wrote:

> Thank you Mervyn,
>
> Once again, it looks like a job for dBase 'Plan B' ...
>
> Guess I will be stealing method and code from Ken's Library.wfm :)
>

I don't think you will find anything suitable in the dUFLP.

What you can do for Plan B is use the rowset's canGetRow event handler
to select the rows that meet the requirement.

A little example is attached.

Mervyn.



** END HEADER -- do not remove this line
//
// Generated on 2020-05-09
//
parameter bModal
local f
f = new test_memo_like1Form()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class test_memo_like1Form of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 20.0455
      left = 12.2857
      top = 0.1364
      width = 112.1429
      text = ""
   endwith

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

   this.FISH1 = new QUERY(this)
   with (this.FISH1)
      left = 3.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)
      dataLink = form.fish1.rowset
      columns["COLUMN1"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN1"])
         dataLink = form.fish1.rowset.fields["name"]
         editorType = 1        // EntryField
         width = 25.5714
      endwith
      columns["COLUMN2"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN2"])
         dataLink = form.fish1.rowset.fields["species"]
         editorType = 1        // EntryField
         width = 29.5714
      endwith
      columns["COLUMN3"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN3"])
         dataLink = form.fish1.rowset.fields["description"]
         editorType = 5        // Editor
         width = 36.7143
      endwith
      with (columns["COLUMN1"].headingControl)
         value = "Name"
      endwith

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

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

      height = 8.2273
      left = 3.0
      top = 4.7273
      width = 101.0
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      onKey = class::ENTRYFIELD1_ONKEY
      height = 1.0
      left = 21.1429
      top = 14.2273
      width = 8.0
      value = ""
   endwith

   this.PUSHBUTTON1 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON1)
      onClick = class::PUSHBUTTON1_ONCLICK
      height = 1.0909
      left = 42.5714
      top = 14.2727
      width = 15.2857
      text = "Select"
   endwith

   this.TEXT1 = new TEXT(this)
   with (this.TEXT1)
      height = 3.0
      left = 15.4286
      top = 15.8182
      width = 25.1429
      text = "Enter search value the press Enter or Tab or click on the Select button. Leave blank to return all records."
   endwith

   this.rowset = this.fish1.rowset

   function ENTRYFIELD1_onKey(nChar, nPosition,bShift,bControl)
      if nchar = 13 or nChar = 9
        class::pushbutton1_onClick()
      endif  
      return

   function PUSHBUTTON1_onClick()
      form.fish1.requery()
      return
      

   function form_onOpen()
      //event handler assigned here as it does not
      //exist when query opens.
      form.fish1.rowset.canGetRow = class::rowset_canGetRow
      return

   function rowset_canGetRow()
     //rowset event handlers don't understand 'form'.
      bRet = false
      if empty(this.parent.parent.entryfield1.value) or;
        upper(this.parent.parent.entryfield1.value)$upper(this.fields['description'].value)
        bRet = true  
      endif  
      return bRet

endclass