> But this does not work when i delete a record
> manually, only when deleting in code.
Hmm, you are working inside Access - with the builtin
Controls - maybe there's something going on under the
hood you have no control over - in VB you can usually
manage these things on your own.
Maybe it helps, if you try to work with the ADO-
Recordsets in disconnected Mode:
Set Rs.ActiveConnection = Nothing
before you bind those Recordsets to the Access-
(Grid-)-Controls.
Olaf
Any changes to data in *any* clone of a given recordset, are instantly
visible in *all* clones, as well as the original recordset. Each clone has
it's own filter, sort and current record pointer, but they all reference the
same data.
If you want to make a copy, as opposed to a clone, create an XML object,
persist the original recordset to it, and open a new recordset using the XML
as the source:
Dim xml As MSXML2.DOMDocument
Set xml = New MSXML2.DOMDocument
rs.Save xml, adPersistXML
rsCopy.Open xml
An alternative would be to use a batch cursor-based recordset, and read the
changes directly from XML. A batch cursor recordset is just a static
recordset (rs.CursorLocation = adUseClient, rs.CursorType = adOpenStatic)
with LockType specified as adLockBatchOptimistic.
Given that the recordset has been persisted as above, the following returns
a node list, one node for each deleted record:
Set DeleteNodes = xml.selectNodes("xml/rs:data/rs:delete/z:row")
In each node, attributes correspond to fields in the recordset, so you can
get the name and value of the first field in the first deleted row like so:
DeleteNodes(0).attributes(0).name
DeleteNodes(0).attributes(0).value
But better to get the attribute by name, because no assumptions should be
made about ordinal positions of the attributes:
DeleteNodes(0).getAttribute("field1")
In fact, you could even easily undelete a row, simply by moving the node up
one row, making it a child of rs:data instead of rs:data/rs:deleted.
This technique may or may not fit your application, but it's likely worth
consideration.
-Mark
> But this does not work when i delete a record manually, only when deleting
> in code.
[quoted text clipped - 79 lines]
>>
>> Olaf
Manfred Senn - 27 Feb 2008 17:58 GMT
Thank you Olaf and Mark for your suggestions.
I solved the problem in another manner,
but I will keep your help in mind for any later programming ...