DataGrid and Adodc recordset handling

Posted on 2003-03-17
Medium Priority
Last Modified: 2013-12-25
High ,
I have a DataGrid (DataGrid1) connected to a Adodc (Adodc1) as the data source.
And I have some button for manipulating the field (Add, Delete, Update).

' --- Set the DataGrid1 and connect it to Adodc1
DataGrid1.AllowAddNew = True
DataGrid1.AllowDelete = True
DataGrid1.AllowUpdate = True
Adodc1.ConnectionString = dlgNewApp1.StrConn
Adodc1.RecordSource = "SELECT * FROM " & dlgNewApp1.recTableName
Set DataGrid1.DataSource = Adodc1

' ---  The Delete button ---
Private Sub cmdDelete_Click()
'    Adodc1.Recordset.CancelUpdate
'    Adodc1.Recordset.CancelBatch
If Adodc1.Recordset.EOF Or Adodc1.Recordset.BOF Then
    MsgBox "There is no record!"

ElseIf IsNull(Adodc1.Recordset) Then
    MsgBox "The field is null, cannot be deleted!"
End If

End Sub

'--- The New button ---
Private Sub cmdNew_Click()
End Sub

' --- The Update button ----
Private Sub cmdUpdate_Click()
If Adodc1.Recordset.EOF Or Adodc1.Recordset.BOF Then

End If
End Sub

My problems are :
1. When I press "Add" , two blank rows (I expect just one )are added in the DataGrid, which cause many inconvenience...

2. When I doubly press  "Add" without filling in the blank rows, then error message:
   "Empty row cannot be inserted. Row must have at least one column value set "
I know that 's because my previous row is empty. Is there any setting to solve this? if no, could you tell me how to write code to prevent ...

I hope there will be some easy trick or setting to deal with these little problem ...

Many Thanks!


Question by:cyyam
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

tat83 earned 80 total points
ID: 8165316
ur second problem is similiar to this question
so take a look at it
it will solve ur second question

Expert Comment

ID: 9095444
No comment has been added lately (141 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to tat83

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --


EE Cleanup Volunteer


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
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…
Suggested Courses

762 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