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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding rows to data entry grid.

Status
Not open for further replies.

mallee

Programmer
Nov 7, 2000
116
I have a data entry grid and am stuck on adding new rows. I append a record in the lost focus event of my last column and this works except although I tell it go bottom and setfocus to first field ,the refresh form ,it dose not go to the new row unless I click on it.
If I do not enter through my last column, of course no new row is added.
Should I append a new record in the beforerowcolchange event ? I would like for the user to be able to click on the first field of an empty row and get a new record.

All suggestions will be appreaciated and attempted.
 
HI Malee,
Have you tried setting the property.
MyGrid.AllowAddNew = .t.

1. This will help adding a blank record when the user pushes the down arrow key while in the last row. I use this effectively.
2. Make sure that before writing the grids rows into the table, validate for data existence or data validations. (The users could leave blank rows.)
3. In the Loast focus event of the last column, you can add code KEYBOARD '{DNARROW}'. This will help to push the cursor one row down automaticaly and this will append the record if necessary (if that is the last row.. if (1) is set).

Hope this helps you :) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
I don't think what you want to do is possible without a LOT of workaround. You can't click on a blank "row" since there isn't actually a control in that location to receive the event. You might be able to interpret it with the Grid.Click() event but you'd have to find some way for the grid to determine if the click was on a record or out of range.

The best thing I can think of would be to have a button outside of your grid to add a new record. Have this code in the button:
Code:
APPEND BLANK
Thisform.Grid1.Refresh()
Thisform.Grid1.SetFocus()
Hope that helps...

Ian
 
Thanks to both of you . I will try your ideas.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top