DataGrid & CancelUpdate

DataGrid & CancelUpdate

Post by Stuart Par » Fri, 01 Oct 1999 04:00:00



I am having problems using the ADO CancelUpdate method when the recordset in
question is a bound to a DataGrid. I would expect to be able to issue an
'AddNew' followed by a 'CancelUpdate' and trigger the recordset's
WillChangeRecord event twice - once for reason adRsnAddNew (=1) and once for
adRsnUndoAddNew (=5). The code below works fine if I remove either of the
lines commented as '1st offender' or '2nd offender' but otherwise, I get a
adRsnAddNew followed by an adRsnUpdate (=3)

Any ideas would be appreciated.

Dim WithEvents rstst As ADODB.Recordset
Private Sub Form_Load()
  Set rstst = New ADODB.Recordset
  With rstst
    .CursorLocation = adUseClient     '1st offender
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .Open "TestTable", FrmMenu.ConnectString, , , adCmdTable
    Set DataGrid1.DataSource = rstst  '2nd offender
    .AddNew                           'should trigger reason 1
    .CancelUpdate                     'should trigger reason 5
    .Close
  End With
  Set rstst = Nothing
End Sub
Private Sub rstst_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum,
ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset
As ADODB.Recordset)
  MsgBox "Change for reason " & adReason
End Sub

Stuart Park

 
 
 

1. rs.CancelUpdate and a DataGrid

Hi,
my problem is: I use some textboxes and an ADO DataGrid to edit data
from an access database. Changes in the datagrid are now immediately
realized in the table of the database, changes in the textboxes are
not.
When the user cancels the edit session, rs.CancelUpdate works only
with the textboxes but not with the datagrid. What do I have to do?

Thanks for your help in advance!

Werner

2. Web products - what's the difference?

3. Problem: CancelUpdate FAILS for a DataGrid bound to Oracle database

4. Garbage Out

5. DataGrid adn RecordSet.CancelUpdate

6. calculated values in sql: extending the decimal

7. datagrid and cancelupdate (Help Please)

8. Oracle to AS/400

9. Urgent--Datagrid &ADO & ORACLE

10. Datagrid & recordset-update

11. DataGrid & Recordset question

12. adodb & Datagrid

13. DataEnvironment & Datagrid Dilema