Reputation: 37
A grid grdmain has a recordsource cDetail. cDetail is a cursor with just 2 columns :
CREATE CURSOR cDetail (tProd C(16), tValue N(4))
A button on the form can reposition to a different row in the grid:
cmdPosition.Click()
SELECT cDetail
GOTO <record>
Thisform grdmain.setfocus()
. . . This works fine.
I would now like to be able to reposition on a row in the grid by entering a suitable value into Column2.text1 of the grid.
Have included similar code (not including Setfocus()) in the Column2.text1.valid() method, but the selected cell remains on the same row - I must be doing something wrong!
Thanks. Andrew
Upvotes: 0
Views: 1740
Reputation: 506
To do what you're trying to do, you must first set focus AWAY from the grid. The row you're currently focused on interactively will always override any manual GOTO commands. You'll also need to put your code in the LostFocus event handler of the grid column's textbox (to avoid the "Cannot call SetFocus from within a When, Valid" error).
Assume this code is in "Column2.Text1.LostFocus". I have a button on the form named "command1" for this example. Further, I'm arbitrarily going to row 2.
thisform.command1.SetFocus()
GOTO 2
thisform.grdmain.SetFocus()
Upvotes: 2