highlight the current record in the subform

fabrizio19

Registered User.
Local time
Yesterday, 17:48
Joined
Aug 9, 2012
Messages
75
Hello
I have syncronized a form with a subform with the following code:

Private Sub YourField_DoubleClick() 'this code is behind the subform

Dim rs As Object
Dim strLinkValue As String 'value in link field of the subform

strLinkValue = Me![NameOfLinkFieldOnSubform].Value
Set rs = Forms!YourMainForm.Recordset.Clone
rs.FindFirst "[NameOfLinkFieldOnMainForm] = '" & strLinkValue & "'"
Forms!YourMainForm.Bookmark = rs.Bookmark

End Sub
Every thing works fine but now I would like that the row in subform remains selected in the subform when the user doubkeclicks the record in the subform.Now after doublecliking the subform highlight the first row.
Many thanks
f
 
I'm having trouble trying to understand why you'd want to navigate to a different record on your main form by double clicking a record on your sub form. Aren't the records on your sub form linked to the current record on your main form?
If this is not the case and your sub form is an independent set of records (this is not actually a sub form) then I think the scenario you've described is because when the user double clicks the field in the sub form, this triggers an event on the main form and moves the focus to select a different record on your main form. To be able to reset the focus back to the record that was double clicked, you'll need to hold the ID of that record so that it can be used after your event above to reselect it.

David
 
thank you for your reply.
The subform is a query with the same data of the mainform (few of them just the essential).
Thus, you choose the record in the subform and you can edit in the mainform after the doubleclik event.
Now, I would like that the focus was on the record selected with the doubleclik,
At the moment the focus go back to the first record of the subform but in the main form the record choosed by doubleck is correctly shown
Thanks
 
try using a modified version your original code to select the record on the sub form, probably just a question of changing the form and control names to suit

David
 

Users who are viewing this thread

Back
Top Bottom