Solved

Create New Row in DBGrid

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
message box in access 4 51
vb6 connector to SQL Server 2 37
Send outlook email from VBS Script 2 42
VBA - If Bookmark = "XXBOOKMARKXX" then 15 40
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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

792 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