Subject SQL statement not working on the form
From AGOSTINHO <AGOSTINHOTEIXEIRA@YAHOO.COM>
Date Sat, 29 Aug 2020 23:02:20 -0400
Newsgroups dbase.getting-started

Dear Group can anyone help me with the following?
As you can see on the form bellow, I'm trying to do a kind of filter on my database on onlostFocus() using a SQL command line but it does not return any filtering on the GRID.
When using this method direct on the command window(DOT PROMPT)

use products
use products.dbf
ag="AGU"
SELECT * FROM products WHERE merk LIKE '%&ag%'
browse

Than  I get the filtering result by browsing the database file
Please let me know what I'm doing wrong within the form that I can't get the
result as from the command windows.
Thanks



parameter bModal
local f
f = new AGUSTForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class AGUSTForm of FORM
   with (this)
      height = 16.0
      left = 31.7778
      top = 2.44
      width = 40.0
      text = ""
   endwith

   this.PRODUCTS1 = new QUERY(this)
   with (this.PRODUCTS1)
      left = 14.0
      top = 12.0
      sql = 'select * from "C:\Users\HOME_PC\Desktop\dBASEtutorial\PRODUCTS.DBF"'
      active = true
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.products1.rowset
      bgColor = "WindowText"
      height = 8.16
      left = 1.0
      top = 6.24
      width = 39.0
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      onLostFocus = class::ENTRYFIELD1_ONLOSTFOCUS
      height = 2.4
      left = 1.0
      top = 0.96
      width = 23.0
      value = ""
   endwith

   this.rowset = this.products1.rowset

   function ENTRYFIELD1_onLostFocus()
      local ag
      ag=form.entryfield1.value
      SELECT * FROM products WHERE merk LIKE '%&ag%'
      return
      

endclass