problem retaining cursor on same position in subform

S

SF

Hi,

I have a main form with a Combobox and a subform that use to display relate
record when the combobox is selected. In the subform, I have a button to
open another form (frmEditCommune) for editing specific record. When finish
editing and closing the frmEditCommune form, I want the subform to requery
and retain the cursor on the current record. The code below did
requery/refresh the content but move the cursor to the first row of the
subform. Could anyone advice how to maintain the cursor to the previuos
position in the subform?


Dim rst As DAO.Recordset
Dim strCriteria As String

strCriteria = "[TargetCommuneID]=" &
Forms![frmTargetCommuneGeneral]![frmTargetCommuneGeneralSubForm01].Form![TargetCommuneID]


If IsLoaded("frmTargetCommuneGeneral") Then
Forms![frmTargetCommuneGeneral]![frmTargetCommuneGeneralSubForm01].Form.Requery


Set rst = Me.RecordsetClone
rst.FindFirst strCriteria
If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
''
Forms![frmTargetCommuneGeneral]![frmTargetCommuneGeneralSubForm01].Bookmark
= rst.Bookmark
End If
End If
Set rst = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top