keep focus on a subform record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a subform in datasheet view in which the user can double click on a
record's ID number field and open the record in the main form. When this is
done, the record opens up in the main form just fine, but the cursor in the
datasheet form goes back to highlight the first record. I know this doesn't
have any effect on the information in the record in the main form, but I'm
wondering is there a way to keep the focus in the subform as the record that
is now open in the main form?
Thanks,
Julie Sullivan
 
Julie,

Use a memory variable to "remember" the ID clicked on and Find it after you
open the record in the main form. Amend your double click event asf:


Private Sub YourControlName_DblClick(Cancel As Integer)

Dim idCur as Long

'Remember the ID
idCur=Nz(Me.YourControlName,0)

........
'Open the desired record as you do now
......


If idCur=0 Then Exit Sub

'Find the ID again
Me.YourSubFormName.SetFocus
Me.YourControlName.SetFocus
DoCmd.FindRecord idCur

End Sub

Regards/JK


|I have a subform in datasheet view in which the user can double click on a
| record's ID number field and open the record in the main form. When this
is
| done, the record opens up in the main form just fine, but the cursor in
the
| datasheet form goes back to highlight the first record. I know this
doesn't
| have any effect on the information in the record in the main form, but I'm
| wondering is there a way to keep the focus in the subform as the record
that
| is now open in the main form?
| Thanks,
| Julie Sullivan
 
Back
Top