![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am using a disconnected ADO recordset that I bind to my form in Access using VBA. I am able to edit existing records, but deleting them is causing a headache. When you delete record(s) either by clicking Delete Record button or highlighting the row and pressing Delete key, Access stored them in a buffer, then asks user to confirm deletion ("You are about to delete 1 record(s)...") If I click No, the record is still deleted from the recordset! Is this just a bug with ADO? I have verified in code that the record has been removed from the recordset after I say "No" to the delete. Therefore it cannot be the form misrepresenting the underlying recordset. I cannot bind directly to the table - there is business logic in the middle filtering the results so I need to use ADO. I know there are workarounds - add another column for user to click on, then I can handle all deletion logic myself, but this is not ideal. Does anyone know how to fix this bug with Access? |
#3
| |||
| |||
|
|
You could cancel the form's delete event then supply your own code to do the delete. "billy_tech" <misterho... (AT) googlemail (DOT) com> wrote in message news:08c2b5d7-9efc-4530-b189-53dcf5defcb8 (AT) u26g2000yqu (DOT) googlegroups.com... |
#4
| |||
| |||
|
|
You could cancel the form's delete event then supply your own code to do the delete. "billy_tech" <misterho... (AT) googlemail (DOT) com> wrote in message news:08c2b5d7-9efc-4530-b189-53dcf5defcb8 (AT) u26g2000yqu (DOT) googlegroups.com... True, although that would remove the possibility of deleting several rows at once, which is a useful feature. |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Hi Ron thanks for that code Unfortunately, it wouldn't quite work. Firstly, you're relying on mouse click to record the selection. I often type Ctrl+A to highlite all records in datasheet view, then press delete key, so the mouse events are not applicable. Also, at what point are you proposing running the DelSelected() function? It can't run at the BeforeDelConfirm stage, because by this point the records are permanently deleted, even if I click "No" to warning. If I do it in the onDelete, then it's back to original problem that I only want to ask user once for confirmation, even if they select multiple records. I'm wondering if, in the OnDelete event, I can check if the record is the last one in the selection. If it is, then I can delete all of them, otherwise cancel the deletion (but add it to the collection of rows to delete). I reckon something like Dim PurchasesToDelete as Integer 'Global var Private Sub Form_Delete(Cancel As Integer) If PurchasesToDelete = Me.SelHeight Then 'call function to delete records, then reset PurchasesToDelete to 0 Else PurchasesToDelete = PurchasesToDelete + 1 End If End Sub |
#7
| |||
| |||
|
|
I am using a disconnected ADO recordset that I bind to my form in Access using VBA. |
#8
| |||
| |||
|
|
billy_tech <misterho... (AT) googlemail (DOT) com> wrote innews:08c2b5d7-9efc-4530-b189-53dcf5defcb8 (AT) u26g2000yqu (DOT) googlegroups.co m: I am using a disconnected ADO recordset that I bind to my form in Access using VBA. Why? -- David W. Fenton * * * * * * * * *http://www.dfenton.com/ usenet at dfenton dot com * *http://www.dfenton.com/DFA/ |
![]() |
| Thread Tools | |
| Display Modes | |
| |