>Also, bear in mind, this fires via Grid.AfterRowColChange()... My point is that the user can tab or cursor up/down many times in a very short time while editing the grid, and this method fires each time, so, I wonder how (a) storing and restoring the Recno() would compare to (b) Using the table again, from a speed standpoint? For some reason, opening and closing the table with every row/col change seems like it would be slow and "heavy" activity, whereas just moving the pointer back would be a lot leaner.
>
>It's easy enough to test each method. I'll let you know how it turns out.
>
>Regardless of this case, I like knowing about this approach in general. I'm sure I'll have plenty of places to use it.
>
>Thanks for sharing.
>
>
>
>>>>Why are you using SQL to do this? You've already got all the data at hand, just save the record pointer, SUM() and restore it.
>>>
>>>This works nicely. And, it DOES work with buffered records. Many thanks.
>>>
>>>It moves the pointer around, which my SQL did not, but that's ok. I store and restore pointer, as you suggested.
>>>
>>>What do you think about this:
>>
>>Alias() is not a safe thing, it will bang in the end if you had nothing in the current workarea. Also, you don't even have to keep the record number... just open your cursor again:
>>
>>
>>Lparameters tiQuoteNo
>>
>>lnSelect=Select()
>>
>>Select 0
>>use dbf("Quote") again alias (sys(2015))
>>Sum (qty*price);
>> For quote_no=tiQuoteNo And Print=.T.;
>> To Thisform.nQuoteTotalPrice
>>use
>>
>>Select (lnSelect)
>>
>>Return Thisform.nQuoteTotalPrice
>>
Hi Matt,
by this situations i've gridTextbox Class to use within a grid and class has a property named lCalcBox (default .f.) and cCalcMethodName ( default empty )
if Condition is valid textbox calling form calculation method which is given at class and calculations running , except no .
By this way there is no cursor or record movement and also unneccessary calculations.
HTH
* textbox gotFocus
With This As TextBox
If .lCalcBox
.Tag = TRANSFORM(.value)
Endif
Endwith
* TextBox LostFocus
With This As TextBox
If .lCalcBox
If _Screen.ActiveForm.addmode=.T. Or _Screen.ActiveForm.editmode=.T.
If Type(.ControlSource)='N' Or Type(.ControlSource)='Y'
If .Value # Val(.Tag)
lcMethodName = This.cCalcmethodname
_Screen.ActiveForm.&lcMethodName
Endif
Else
If .Value # .Tag
lcMethodName = This.cCalcmethodname
_Screen.ActiveForm.&lcMethodName
Endif
Endif
Endif
Endif
Endwith