Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    set focus (2002)

    I have a form with a subform in a tabcontrol. I am assigning the souce object to the subform in a tabcontol change event.

    Case 2
    If Me.frmdetail.SourceObject = "" Then
    Application.Echo False
    Me.frmdetail.SourceObject = "frmdetail"
    Me.frmdetail.LinkChildFields = "Case_ID"
    Me.frmdetail.LinkMasterFields = "Case_ID"
    Application.Echo True
    Forms!frmcases!frmdetail.Form!txtVIN.SetFocus
    End If

    The problem is I cannot set focus to the first field in the sub-form. Any ideas?

    Thanks a lot.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: set focus (2002)

    To set focus to a control in a subform, you must first set focus to the subform, and then to the control:

    Forms!frmcases!frmdetail.SetFocus
    Forms!frmcases!frmdetail.Form!txtVIN.SetFocus

    If frmcases is the active form, you can replace this by

    frmdetail.SetFocus
    frmdetail.Form!txtVIN.SetFocus

    and you can probably omit the .Form in the second instruction.

  3. #3
    New Lounger
    Join Date
    Aug 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: set focus (2002)

    Sorry, this didn't work. If I click on a diiferent tab and then come back to this tab, the correct control has focus.

    Thanks.

    Dilip

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: set focus (2002)

    Don't know if this will work, but you might try inserting an instruction

    Me.frmdetail.Form.Requery

    after changing the source of the subform and before setting the focus.

  5. #5
    New Lounger
    Join Date
    Aug 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: set focus (2002)

    That didn't work. Thanks for your quick responses.

    Dilip

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: set focus (2002)

    I hope someone else has better ideas. It's difficult to determine what's happening without being able to look at the database.

    Note: If it's not too much trouble, you might consider making a copy of the database, removing all objects not relevant to the problem, replacing the real data by a few non-sensitive dummy records, and then compact, zip and attach this copy to a post. I'm sure another Lounger will find the time to look at it.

  7. #7
    New Lounger
    Join Date
    Aug 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: set focus (2002)

    Thanks for your help. You lead me in the right direction. I had to have the visible property set to no for the unbound subform. Then, I had to turn the visible property to yes after assigning a sourceobject..

    Case 2
    If Me.frmdetail.SourceObject = "" Then
    Application.Echo False
    Me.frmdetail.SourceObject = "frmdetail"
    Me.frmdetail.LinkChildFields = "Case_ID"
    Me.frmdetail.LinkMasterFields = "Case_ID"
    Me.frmdetail.visible=true
    Application.Echo True
    Forms!frmcases!frmdetail.setfocus
    Forms!frmcases!frmdetail.Form!txtVIN.SetFocus
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •