I have a form that mimics a split form. I do not use split forms since my control over their layout is limited. My form is basically a normal form with a subform in it. The subform displays the same records in datasheetview. When the user selects a record on the subform, the subform runs the following procedure as its current event procedure, and moves the parent form to the record the user selected.
the code works as intended, but not always. The main form always moves to the the record the user clicked, no problem there. But the very subform that the user clicked on does not always move to the clicked record. Sometimes it stays at its current position, sometimes it moves to an unrelated record.
As I watch the program flow, I notice that sometimes the execution of line number 60 is not followed by line 70. It jumps back to line 10, and is executed again. I would expect this behavior if it were the subform's cursor that moved to a different record, but it isn't. Line 60 only moves the cursor of the main form. There's no link between the subform and the main form (their recordsources are different and no parentID-childID link is established.
Any ideas?
Code:
10 Private Sub Form_Current()
20 Dim rstKlon As Recordset
30 If Me.Parent.pstrPKField <> vbNullString 'just a checkpoint
40 Set rstKlon = Me.Parent.RecordsetClone
50 rstKlon.FindFirst "NoteID=" & Me![NoteID]
60 Me.Parent.Bookmark = rstKlon.Bookmark
70 End If
80 Set rstKlon = Nothing
90 End Sub
As I watch the program flow, I notice that sometimes the execution of line number 60 is not followed by line 70. It jumps back to line 10, and is executed again. I would expect this behavior if it were the subform's cursor that moved to a different record, but it isn't. Line 60 only moves the cursor of the main form. There's no link between the subform and the main form (their recordsources are different and no parentID-childID link is established.
Any ideas?
Last edited: