Hi to all,
I'm a quite new programmer in VFP and I'd like to submit you a strange behaviour that I encounter using cursor.
Let's say I have a cursor (populated scanning a file, so I've no dbf) that is a record source for a grid.
This cursor has a field named selected, logical type. I use this field for controlsource of a checkbox column in the grid, so a user can select/unselect rows in the grid. The problem arises when I make a query on the cursor counting how many rows are currently selected
select count(*) as C from curRett where selected = .T. into cursor curTemp
n = curTemp.C
...
The problem is that the query return a number of selected rows that is greater than 1 of the real value.
I run this query when the column with the checkbox change value. When I deselect it seems not recognise that the row is in fact deselected.
I've tried watching value of currett.selected on current row and correctly it's false, so cursor seems to have updated values.
BUT, the code works if I write this
select curRett
browse
select count(*) as C from curRett where selected = .T. into cursor curTemp
n = curTemp.C
...
The browse, I don't know why, makes the following query works correctly. Obviously I can't use browse in real world application so I resolved in this way
i = 0
SCAN
IF currett.selected = .T.
i = i + 1
ENDIF
ENDSCAN
return i
I've tried with nofilter in select but nothing change. I can't understand what I'm missing. The data in cursor before the query are correct as browse can demonstrate but the query seems to use old value. I recently encounter another similar problem: when I query on a cursor the where doesn't filter correctly the values but if I make a browse before the query all goes right.
Thank you very much for you help!
I'm a quite new programmer in VFP and I'd like to submit you a strange behaviour that I encounter using cursor.
Let's say I have a cursor (populated scanning a file, so I've no dbf) that is a record source for a grid.
This cursor has a field named selected, logical type. I use this field for controlsource of a checkbox column in the grid, so a user can select/unselect rows in the grid. The problem arises when I make a query on the cursor counting how many rows are currently selected
select count(*) as C from curRett where selected = .T. into cursor curTemp
n = curTemp.C
...
The problem is that the query return a number of selected rows that is greater than 1 of the real value.
I run this query when the column with the checkbox change value. When I deselect it seems not recognise that the row is in fact deselected.
I've tried watching value of currett.selected on current row and correctly it's false, so cursor seems to have updated values.
BUT, the code works if I write this
select curRett
browse
select count(*) as C from curRett where selected = .T. into cursor curTemp
n = curTemp.C
...
The browse, I don't know why, makes the following query works correctly. Obviously I can't use browse in real world application so I resolved in this way
i = 0
SCAN
IF currett.selected = .T.
i = i + 1
ENDIF
ENDSCAN
return i
I've tried with nofilter in select but nothing change. I can't understand what I'm missing. The data in cursor before the query are correct as browse can demonstrate but the query seems to use old value. I recently encounter another similar problem: when I query on a cursor the where doesn't filter correctly the values but if I make a browse before the query all goes right.
Thank you very much for you help!