This works for me:
Local AddNew As Boolean
AddNew = .F.
Try
With This.Parent
If Reccount(._Grid1.RecordSource) = 0
Select (._Grid1.RecordSource)
Append Blank
AddNew = .T.
Endif
._Grid1.SetFocus
._Grid1.ActivateCell(Reccount(._Grid1.RecordSource),2)
If Not AddNew
Keyboard '{DNARROW}'
Keyboard '{ENTER}'
Endif
Endwith
Catch To oException
oException = Null
Endtry
HTH
>Hi Everybody,
>
>Having problem with grid....
>When user double click to make the grid-column-cell highlighted and press on the add button (which is functioning to insert a blank record in remote view), the grid will be added for two lines. When delete a line also, same problem. My coding details go as follow:
>
>*!*For Add New Line Button Click Method*!*
>SELECT fdetail
>count for not deleted() to lnline
>*!* append blank in fdetail (same problem by using this)
>INSERT INTO fdetail(line_no) values(lnline+1)
>
>*!* thisform.pageframe1.page2.grid1.refresh
>thisform.refresh
>thisform.pageframe1.page2.grid1.column1.setfocus
>
>*!*For Delete Line Button Click Method*!*
>delete in fdetail
>if !bof()
> skip -1
>endif
>
>SELECT fdetail
>lnlineno=fdetail.line_no
>go top
>do while !eof()
> replace fdetail.line_no with lnno IN fdetail
> lnno=lnno+1
> SELECT fdetail
> SKIP
>ENDDO
>if lnlineno<>0
> locate for fdetail.line_no=lnlineno
>endif
>Thisform.Refresh
>thisform.pageframe1.page2.grid1.column1.setfocus
>
>Those codes work fine for normal operations. But once user selected the grid cell by double clicking and highlighted the field, the problem encountered there.
>
>Remarks : Those codes are working in Form Class Level. The actual working form is derived from the form class.
>
>Hope to get some help on it.
>
>Thanks & much appreciates in advance,
>Mya.
Peter Pirker
Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?
(Woody Allen)