When I'm working with a grid I newer use setfocus(), too much trouble with it. Try the Thisform.Grid.ActivateCell(nRow, nCol) instead, works very well, or sometimes I use KEYBOARD '{RIGHTARROW}' to move across the grid.
/Mårten Törnquist
>I have a page frame with two pages. Each page has a grid, which is the only control on each page. Whenever the user activates a page I want focus to be on the grid. To do this I have placed the following code in the Activate event on each page:
>
>THISFORM.pageframex.pagex.gridx.SetFocus
>
>On each grid, if the user enters a valid account number in column 1, I want to skip to column 4. To do this I set a public variable gl_ok to true in the Valid of the text box in column 1 and then have the following code in the LostFocus event of that text box:
>
>IF gl_ok = .T.
> This.Parent.Parent.Column4.text1.SetFocus
>ENDIF
>
>Sometimes this works, but often the focus goes from Column 1 to Column 2. Other times it goes from Column 1 to the page tab then to Column 4. I set step on and what seems to be happenning is that when I try to set focus on Column 4, the code in the Activate event is executed, which overides the set focus in the LostFocus event.
>
>What code should I use, and where should I place it, to get the focus to behave as I want?
---( Mårten Törnquist )---