keep focus on a subform record

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
 
J

JK

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
 

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