in the BeginUpdate event of a subform, I want to write a copy of the current record to a collection. In the AfterUpdate event I want to change one field of the record, that has been updated, and I want to add a new record containing some of the fields that were written to the collection in the BeforeUpdate event.
I had to notice, that the record to which Me.Recordset points when BeginUpdate and AfterUpdate are called, is not the one that is currently being updated. Me.CurrentRecord, however, points to the correct record. What is the "correct" way to select the record being updated in order to write a copy into a collection (in BeginUpdate), and to alter the field in the AfterUpdate method?
I don't want to use the controls (Me.ID, Me.Name, ...) (which contain the correct values), since I want to use the same code for several (sub-)forms (which point to different tables with different fields). I intended to simply loop through the fields of the recordset. Something like:
For i = 1 to rst.RecordCount
myColl.Add rst.Fields(i), rst.Fields(i).Name
I've tried to set rst.AbsolutePosition in the Before/AfterUpdate methods, however this leads to an error. I might want to always track the position in the OnCurrent event, but this solution looks rather like a hack to me...
Any suggestions on how the read/write the correct record in the Before/AfterUpdate methods?