Subject |
Like query |
From |
Tom <IHaveNoEmail@ddress> |
Date |
Tue, 24 May 2022 14:23:15 -0400 |
Newsgroups |
dbase.getting-started |
Attachment(s) |
Invoice.png |
dBase 13.1
Windows 10 Pro
Version 21H2
Having stolen one of Mervyn's sample forms, I have changed databases,
tables and fields for a trial. The field name contains a space but
otherwise is a character field. Using single quotes, double quotes and
brackets around the field name still fails to 'find' any entries I type.
Ultimately, I would like to use 'like' with the date field in the table too.
Would you be so kind as to show me how to get this form to work. A copy
of the sample form and a screenshot of the table design are included.
Thanks,
Tom
*
** END HEADER -- do not remove this line
//
// Generated on 05/24/2022
//
parameter bModal
local f
f = new like_searchForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class like_searchForm of FORM
with (this)
onOpen = class::FORM_ONOPEN
height = 17.5909
left = 13.4286
top = 0.0
width = 95.8571
text = ""
endwith
this.DBASETUTORIAL1 = new DATABASE(this)
with (this.DBASETUTORIAL1)
left = 12.0
width = 11.0
height = 1.0
databaseName = "DBASETUTORIAL"
active = true
endwith
this.INVOICE1 = new QUERY(this)
with (this.INVOICE1)
left = 26.0
width = 9.0
height = 1.0
database = form.DBASETUTORIAL1
sql = [select * from INVOICE.DBF where lower('Card Name') like :search]
params["search"] = '%'
active = true
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
dataLink = form.INVOICE1.rowset
height = 8.6364
left = 5.1429
top = 3.0909
width = 77.7143
endwith
this.RADIOBUTTON1 = new RADIOBUTTON(this)
with (this.RADIOBUTTON1)
height = 1.0909
left = 11.4286
top = 13.0
width = 15.7143
text = "Contains"
group = true
value = true
endwith
this.RADIOBUTTON2 = new RADIOBUTTON(this)
with (this.RADIOBUTTON2)
height = 1.0909
left = 10.7143
top = 15.4091
width = 15.7143
text = "Begins with"
endwith
this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
onKey = class::ENTRYFIELD1_ONKEY
height = 1.0
left = 38.5714
top = 14.1818
width = 17.4286
value = " "
endwith
this.TEXTLABEL1 = new TEXTLABEL(this)
with (this.TEXTLABEL1)
height = 1.0
left = 35.5714
top = 13.0
width = 23.5714
text = "Search for (case insensitive)"
endwith
function ENTRYFIELD1_onKey(nChar, nPosition,bShift,bControl)
***if nChar = 13 //uncomment to prevent requery until Enter is
pressed
if form.radiobutton1.value = true
form.INVOICE1.params['search'] =
'%'+trim(lower(form.entryfield1.value))+'%'
else
form.INVOICE1.params['search'] =
trim(lower(form.entryfield1.value))+'%'
endif
if empty(form.entryfield1.value)
form.INVOICE1.params['search'] = '%'
endif
form.INVOICE1.requery()
***endif
return
function form_onOpen()
form.entryfield1.setfocus()
return
endclass
|
|