Post by Geoff Wass [dBVIPS]Rich,
Returns the number of rows in a rowset, respecting any filter conditions
and events.
canGetRow is not mentioned as on of the things ROWSET.count() respects.
Perhaps dBI should be asked to clarify the documentation.
I checked some other places, and I have (successfully) used the
rowset.count() method to correctly return the number of records meeting
a condition. I interpreted from the OLH that canGetRow is a "filter
condition and event", even though canGetRow is not specifically
mentioned.
Nonetheless, this quick example form demonstrates that what didn't work
in the command window works in a form .... either hard-coded or as the
macro-substituted variable....
Thanks, Rich
-----------------------------------------------------------------
/* This didn't work in command window:
q = new query('select * from :dBaseSamples:Fish')
q.rowset.cangetRow = {||this.fields['Name'].value == 'Blue'}
? q.rowset.count() // 10 = not filtered at all! Should be 2
*/
** END HEADER -- do not remove this line
//
// Generated on 10/30/2008
//
parameter bModal
local f
f = new bugcangetrowForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class bugcangetrowForm of FORM
with (this)
height = 16.0
left = 68.7143
top = 0.7273
width = 80.2857
text = "CanGetRow Behavior"
endwith
this.DBASESAMPLES1 = new DATABASE()
this.DBASESAMPLES1.parent = this
with (this.DBASESAMPLES1)
left = 74.7143
top = 14.7727
databaseName = "DBASESAMPLES"
active = true
endwith
this.FISH1 = new QUERY()
this.FISH1.parent = this
with (this.FISH1)
left = 74.7143
top = 14.7727
database = form.dbasesamples1
sql = "select * from fish.dbf"
active = true
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
dataLink = form.fish1.rowset
height = 8.1818
left = 3.8571
top = 1.3636
width = 72.1429
endwith
this.TEXTLABEL1 = new TEXTLABEL(this)
with (this.TEXTLABEL1)
height = 1.0
left = 7.4286
top = 10.4545
width = 22.5714
text = "CanGetRow to Fish Name:"
endwith
this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
height = 1.0
left = 32.7143
top = 10.2273
width = 15.5714
value = ""
endwith
this.TEXTLABEL2 = new TEXTLABEL(this)
with (this.TEXTLABEL2)
height = 1.0
left = 51.7143
top = 10.2273
width = 20.2857
text = "Matching Fish:"
endwith
this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = class::PUSHBUTTON1_ONCLICK
height = 1.0909
left = 11.1429
top = 12.2727
width = 19.2857
text = "Set canGetRow"
endwith
this.PUSHBUTTON2 = new PUSHBUTTON(this)
with (this.PUSHBUTTON2)
onClick = {;form.rowset.canGetRow = {||.t.}}
height = 1.0909
left = 39.2857
top = 12.2727
width = 20.8571
text = "Clear canGetRow"
endwith
this.rowset = this.fish1.rowset
function PUSHBUTTON1_onClick
private cFishName
cFishName = trim(form.entryfield1.value)
// >>> hard coded or not, both lines work <<<<<<<<
*form.rowset.canGetRow = ;
{||this.fields['Name'].value = "&cFishName."}
form.rowset.canGetRow = ;
{||this.fields['Name'].value = "Blue"}
nRecs = form.rowset.count()
form.textLabel2.text := ;
'Matching Fish: '+nRecs
return
endclass