Ravindra Patil
Programmer
I have a grid control on m0y form. When the user presses Enter or Tab in the last column, I want the first cell in next row should get the focus. I tried by inserting following code in last column's text1's LostFocus. But the control remains in that row only.
thisform.addrow(.t.,this.Parent.Parent.RecordSource)
this.Parent.Parent.Refresh
ThisForm.Mytxtbox11.Value=RECNO('_aggre')
ThisForm.Mytxtbox11.Refresh
This.parent.parent.ActivateCell(RECNO('_aggre')+1,1) &&column2.SetFocus()
Code for Form's addrow method is as follows;
PARAMETERS add_row,tbl
if INLIST(LASTKEY(),13,9,24) OR add_row
SELECT sr_no FROM &tbl WITH (buffering=.t.) WHERE INLIST(.t., EMPTY(date), EMPTY(size), EMPTY(agency), EMPTY(AMOUNT)) AND !DELETED() INTO ARRAY a_sn
SELECT &tbl
IF _tally>0
MESSAGEBOX("Sr.No : "+TRANSFORM(a_sn[1])+" -> The fields date, size, quantity, rate, agency are compulsory.",64,"Attention please!")
ELSE
oldsn= sr_no
LOCATE FOR sr_no=oldsn+1
IF !FOUND()
APPEND BLANK
this.justadded=RECNO()
GO this.justadded && purposely inserted to avoid error
REPLACE cont_code WITH contracts.code, sr_no WITH oldsn+1
if ThisForm.Add_mod_del1.isadding
REPLACE date WITH date()
endi
ENDIF
ENDIF
ENDIF
thisform.addrow(.t.,this.Parent.Parent.RecordSource)
this.Parent.Parent.Refresh
ThisForm.Mytxtbox11.Value=RECNO('_aggre')
ThisForm.Mytxtbox11.Refresh
This.parent.parent.ActivateCell(RECNO('_aggre')+1,1) &&column2.SetFocus()
Code for Form's addrow method is as follows;
PARAMETERS add_row,tbl
if INLIST(LASTKEY(),13,9,24) OR add_row
SELECT sr_no FROM &tbl WITH (buffering=.t.) WHERE INLIST(.t., EMPTY(date), EMPTY(size), EMPTY(agency), EMPTY(AMOUNT)) AND !DELETED() INTO ARRAY a_sn
SELECT &tbl
IF _tally>0
MESSAGEBOX("Sr.No : "+TRANSFORM(a_sn[1])+" -> The fields date, size, quantity, rate, agency are compulsory.",64,"Attention please!")
ELSE
oldsn= sr_no
LOCATE FOR sr_no=oldsn+1
IF !FOUND()
APPEND BLANK
this.justadded=RECNO()
GO this.justadded && purposely inserted to avoid error
REPLACE cont_code WITH contracts.code, sr_no WITH oldsn+1
if ThisForm.Add_mod_del1.isadding
REPLACE date WITH date()
endi
ENDIF
ENDIF
ENDIF