Solved

Create New Row in DBGrid

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

13 Experts available now in Live!

Get 1:1 Help Now