Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Entering data into grid
Message
From
27/12/2002 06:50:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00735860
Message ID:
00736009
Views:
10
Chuck,
Sorry I missed your 'notes' before.


>Cetin, I am not sure you addressed the fact that when the amount field has cents (ie..1300.55 vs 1300.00), the valid event does not appear to fire because it does not sense a keypress or lastkey. I think there is a default of an "end of input" and since it is the last field in the grid it defaults to the first field instead of "arrowdown". Look at my notes: by the way I appreciate you cleaning up my code.
>Thanks
>>
>>Chuck,
>>I couldn't see a relation of this code to valid. It always returns .T., right ?
>>I wouldn't count and sum all records all the time. It might be really time consuming as reccount increases.
>>
>>
>>*Initialize - ie: in form.init
>>local array arrCompute[1]
>>set deleted on
>>select sum(amt) from myTable into array arrCompute
>>
>
>*** is this in the valid ?

No this is in form init when buffered records not yet changed (otherwise SQL wouldn't sum() buffered ones. We only need initial sum and count to be computed.


>>WITH ThisForm
>>     .txtEnterTotal.VALUE=iif(_Tally=0,0,arrCompute)
>>     .txtTotRecCnt.VALUE=_Tally
>>ENDWITH
>>
>*** since there are no ADD/EDIT buttons
>*** how do you know when a record has been added or deleted
>*** maybe create a method for the init call and use it in
>*** the valid also?

There is no add or delete buttons right. But 'add' is done when 'dnarrow' at bottom. Grid's deleted (do you allow deletes?)  event fires when record is deleted using the leftmost delete mark.


>>*Any code adding to table also calls
>>WITH ThisForm.txtTotRecCnt
>> .VALUE=.Value+1
>>ENDWITH
>>
>>*Any code deleting from table also calls
>>WITH ThisForm.txtTotRecCnt
>> .VALUE=.Value-1
>>ENDWITH
>
>>
>
>please explain why i would use this.tag?

It simply holds the 'old value' that's contributing to current sum. In lost focus we subtract the old value and add new value (thus add only delta of new,old to sum). Textbox.tag is a ready free storage property.


>>*TxtAmt.GotFocus
>>this.Tag = trans(this.Value)
>>
>>*TxtAmt.LostFocus
>>WITH ThisForm.txtEnterTotal
>> .VALUE = .Value + (this.Value - val(this.Tag))
>>ENDWITH
>>if !mdown() and inlist(lastkey(),13)
>> keyboard '{DNARROW}'
>>endif
>
>*** I had this set to true

If is set to true then you don't need append blank. Grid adds new record if at last row + dnarrow is pressed. Checking eof() in a grid is not reliable because grid doesn't let an eof() as refresh fires (I don't mean it never occurs but it positions itself to last one).

>>*Grid.AllowAddNew= .t. would handle adding the new record if at bottom
>>
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform