Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Entering data into grid
Message
From
26/12/2002 13:14:13
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00735860
Message ID:
00735887
Views:
10
>Does anyone know the best way to make the cursor move to the next line in a grid when the enter key is pressed on the last field (amount) and the value has cents. Anotherwards, the default action never fires the valid where the test for the keypress is. If I put code in the keypress event it makes the grid behave weird. This is the code in the valid:
>
>* Method.:txtamt.valid
>* Modified 12/26/2002 by CWILLIAMS
>
>* calculate the total of all non-deleted records
>* and calulate the total number of records to display
>* a running total of each for all input
>* 13=enter key
>* 24=downarrow
>LOCAL nKey
>nKey = LASTKEY()
>LOCAL lnTmpTotal,lnToCnt
>lnTemp=RECNO()
>COUNT FOR !DELETED() TO lnTotCnt
>lnTmpTotal=0
>GO TOP
>DO WHILE NOT EOF()
>	IF !DELETED() then
>		lnTmpTotal=lnTmpTotal+amt
>	ENDIF
>	SKIP
>ENDDO
>
>GOTO lnTemp
>WITH ThisForm
>     .txtEnterTotal.VALUE=lnTmpTotal
>     .txtTotRecCnt.VALUE=lnTotCnt
>ENDWITH
>* add new record if downarrow or enter key pressed
>IF nKey= 13 OR nKey= 24
>	KEYBOARD '{DNARROW}'
>	IF EOF()
>		GO BOTTOM
>		APPEND BLANK
>	ENDIF
>ENDIF
>THIS.REFRESH
>
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

WITH ThisForm
     .txtEnterTotal.VALUE=iif(_Tally=0,0,arrCompute)
     .txtTotRecCnt.VALUE=_Tally
ENDWITH

*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

*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
*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
Next
Reply
Map
View

Click here to load this message in the networking platform