This one is stumping me!
I have a Form/Subform arrangement. The main form is set as a Single
Form and the sub form is set as Continuous Forms.
On the Form_AfterUpdate event of the subform, I run some code that
affects the main form which forces focus *away* from the subform and
puts it to the main form.
I need to keep focus on the subform when the code in the
Form_AfterUpdate event finishes. Sounds simple enough, right!? I
tried a Me.CtrlName.SetFocus in the subform after I'm done running my
code. However, in continuous forms, it defaults back to the *first*
row. I'm wanting to set focus back to a specific row/instance in the
subform.
I tried DoCmd.RunCommand acCmdRecordsGoToLast and the like, but I want
to get focus to where I last left off, not the first, last, new, etc.
record.
I do have a hidden unique identifier if that would be used as part of
the solution.
Any thoughts? If you need more info, let me know!
Thanks,
Kael
kaeldowdy@hotmail.com - 30 Mar 2006 18:34 GMT
Well, I think I got it figured out. It was easier than I thought...
Form_AfterUpdate()
Dim lngPosition as Long
lngPosition = Me.CurrentRecord ' capture index position of record
currently selected
' *** do my code where my subform loses focus to parent form ***
Me.ControlName.SetFocus ' go back to sub form
Me.Form.Recordset.Move lngPosition ' navigate back to original
record position
End Sub
I still have some debugging to be sure its fine tuned correctly to
account for all possible situations, but this got me 90% of the way
there. I guess it was easier than I thought (Me.CurrentRecord and
Me.SelTop didn't jump out at me at first!)
Thanks!