Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Navigating in a grid. 1

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB

I have a grid which is used to accept a variable number of records. The recordsource is a cursor, tDetail; this has one empty record when the grid first receives focus.

After the user has entered data into one or more rows, if the records validate correctly they may be posted; the form moves onto the next transaction - clearing the grid by re-creating cursor tdetail.

This works fine. However, when the last cell in the last row loses focus, I would like to create a new record in tdetail if we are located on the last record of tdetail.

To do this, I APPEND a blank record to detail, go to the BOTTOM of tdetail, and (for good measure) try to move to the bottom row of the grid, with this code :

Code:
SELECT tDetail
APPEND BLANK
GO BOTTOM
.grdmain.column1.SetFocus()
KEYBOARD "{DNARROW}"

There is probably some redundant code here – (have tried several instructions to move focus to the new last row of the grid). However I am finding that focus is not set to the new (empty) last row, but still to the row which has just been completed.

If however I insert a breakpoint (using SET STEP ON or by using the F9 key), just before the above code, the form works fine : after RESUMEing the program the focus is indeed set to the last row.

How should I set focus to the first cell in the newly created last row?

Thanks. Andrew
 
Have you treid this
.grdmain.column1.Text1.SetFocus()
 
Thank you, AZsoft - that is a great improvement - solves the problem. I believe that that is what I meant to code, but since the .grdmain.column1.SetFocus() executed OK, I took no more notice.

You have been a great help. Andrew M.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top