Set focus to particular record using Continuous Forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kaeldowdy@hotmail.com

    #1

    Set focus to particular record using Continuous Forms

    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_AfterUpdat e 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_AfterUpdat e event finishes. Sounds simple enough, right!? I
    tried a Me.CtrlName.Set Focus 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.RunComman d acCmdRecordsGoT oLast 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

    #2
    Re: Set focus to particular record using Continuous Forms

    Well, I think I got it figured out. It was easier than I thought...

    Form_AfterUpdat e()
    Dim lngPosition as Long

    lngPosition = Me.CurrentRecor d ' 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.Records et.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.CurrentReco rd and
    Me.SelTop didn't jump out at me at first!)

    Thanks!

    Comment

    Working...