Set focus in a specific record within a subform

K

KJL

I have a main form with a subform. The subform contains multiple records and
a hidden unique id which ties it to the main form. After I enter data into a
field on the subform, I am requering the main form. I would like the focus
to remain on the subform on the specific record the user is editing. I have
been able to get the focus to remain the subform however, the focus jumps to
the first record.

Any ideas?
This is my code:

Private Sub MP_Reserve_AfterUpdate()
Forms!Liability.Form.Requery
Forms!Liability!ClmntInfoForm!.SetFocus
Forms!Liability!ClmntInfoForm!.Form![BI Reserve].SetFocus

End Sub
 
T

Tore

I guess you could use the bookmark property of your subform:

http://msdn.microsoft.com/en-us/library/aa194054(office.10).aspx

Save the bookmark of the subform when you have selected the record and use
it whenever you need to go back to this subform record. I guess you could
declare a string variable to hold the bookmark in the header section of the
subform vba code.

Dim StrBookmark as string
strBookMark = me.bookmark
me.bookmark = strbookmark

Bookmarks are destroyed in situations as described in the article.

Regards
 

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