?
Solved

Create New Row in DBGrid

Posted on 1999-01-11
5
Medium Priority
?
219 Views
Last Modified: 2013-12-25
I have an unbound DBGrid which I would like users to be able to add new rows to at run-time.  They are able to add the first row, but when they try to click in the next row, nothing happens.  The AllowAddNew property is set to True.  I tried setting the rowbookmark on the unboundadddata event.  When I do that, it allows me to add a new row, but the first row is overwritten by the data entered into the new row.
0
Comment
Question by:ZVE
5 Comments
 

Author Comment

by:ZVE
ID: 1489560
Adjusted points to 100
0
 

Expert Comment

by:jmnolan
ID: 1489561
When you add a new row it erases the data that you are entering in the current row. You have to save the data from the grid to the array you are using to store your data. A good way to do it is to check the CurrentCellModified property to see if you do actually need to save it. Let me know if this helps!
0
 

Expert Comment

by:jaggoo
ID: 1489562
Question is not clear whether DBGrid's "AddNew" method was used to insert a new row in the grid. If not used, row pointer will not get shifted. Hence, rows are overwritten at current row edit.

0
 
LVL 1

Expert Comment

by:RamRam111798
ID: 1489563
check the sample Unbndgrd.vbp in samples directory
0
 
LVL 8

Accepted Solution

by:
vettranger earned 200 total points
ID: 1489564
AllowAddNew only applies when letting the user add records to a recordset object bound to the dbgrid control.

For your purpose, you need to control the grid yourself with the .row property in connection with the rowcolchange event.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question