Solved

Create New Row in DBGrid

Posted on 1999-01-11
5
210 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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

862 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now