• Setting focus in a subform (Access 2000 SR1a)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Setting focus in a subform (Access 2000 SR1a)

    Author
    Topic
    #374714

    Question on setfocus: I have a tab control on my main form where each tab contains a subform. When my user exits (tabs or enters) from the last field I would like the focus to go to the first field in the subform on the first tab. This is what I tried but it only sets the focus to the tab not the field in the subform

    Private Sub Designer_LostFocus()
    ‘Move Cursor to Plant Subform
    frmProposalPlant!ItemQty.SetFocus

    End Sub

    frmProposalPlant is the name of the subform and ItemQty is the name of the first field on the subform. One other thing to note is the subform is a continuous form.

    Thanks in advance
    Tom

    Viewing 0 reply threads
    Author
    Replies
    • #607061

      Try setting focus to the subform first, then to the control in the subform:

      frmProposalPlant.SetFocus
      frmProposalPlant!ItemQty.SetFocus

      This should set focus to the ItemQty field, but if you have visited the subform previously, the focus will remain in the record that was current before.

      If you want the first record to become active, add an instruction:

      RunCommand acCmdRecordsGotoFirst

      • #607064

        That worked beautifully. Thank you
        Tom

        • #607079

          Hi Tom

          You may to look at this for future reference

          Dev Ashish has the best table I’ve seen for trying to figure out sub and sub-sub form controls and such: Refer to Form and Subform properties and controls. In addition to a great description, you can download the table as a Word document. You’ll want to save that for future reference

          http://www.mvps.org/access/forms/frm0031.htm%5B/url%5D

          HTH

          JOhn

    Viewing 0 reply threads
    Reply To: Setting focus in a subform (Access 2000 SR1a)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: