Results 1 to 11 of 11
  1. #1
    altemir is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    31

    Set Focus on Control from Navigation Button

    I have a Navigation Subform several navigation buttons across the top. When I click on one of the navigation buttons, I would like to ensure that a control on the subform under that button receives the focus. This screen is for barcode entry so I want to make sure the form is ready for action when the user clicks on the nav button.

    How do I set focus to the subform control from the navigation button OnEnter event?



    Here is my structure:

    frmMain --> NavigationSubform --> frmBarcodeEntry --> subfrmBarcodeEntry --> txtBarcodeString

    where txtBarcodeString is the textbox control that I want to set focus for.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    Try:

    Forms!mainformname.subformcontainername.Form.contr olname

    I always give subform container control a name different from the object it holds.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    altemir is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    31
    Quote Originally Posted by June7 View Post
    Try:

    Forms!mainformname.subformcontainername.Form.contr olname

    I always give subform container control a name different from the object it holds.
    Thanks, but I tried the following and it didn't work:

    Forms!frmMain.subfrmBarcodeEntry.Form.txtBarcodeSt ring.SetFocus

    I get Error 2465: "Application-defined or object-defined error". Should I even be attempting this in the OnEnter event of the nav button?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    Don't know why not. But I have never used the Navigation control. Don't like it. If you want to provide the project for analysis, will look at.

    Did you name the subform container control different from the form it holds, like ctrBarcode?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    altemir is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    31
    Yes, it has a different name. I think the reason that I can't set focus on the subform is that I am not executing the SetFocus method in the right event, because any of the events associated with the nav button execute BEFORE the subform and its controls even exist. You would think that placing the SetFocus in the OnOpen or OnLoad event of the subform would work, but the focus continues to be stuck on the nav button.

    I even experimented with the OnTimer event to issue a SetFocus command every second after the subform is loaded. I can get a MsgBox to pop up every second, but Me.txtBarcodeString.SetFocus couldn't manage to pull the focus away from the nav button.

    ... Getting desperate here.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    As I said, don't like the Navigation control. I seldom use any of the wizards. Silly question - you tried Click event of the Navigation button?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    altemir is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    31
    Yes, I tried OnClick.

  8. #8
    altemir is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    31
    ... but it didn't work either.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    Do you want to provide project for analysis?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    johanja is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    2

    Did you find a solution?

    Did you find a solution? Because I have the same problem now, can you set me in the right direction?

    Quote Originally Posted by altemir View Post
    I have a Navigation Subform several navigation buttons across the top. When I click on one of the navigation buttons, I would like to ensure that a control on the subform under that button receives the focus. This screen is for barcode entry so I want to make sure the form is ready for action when the user clicks on the nav button.

    How do I set focus to the subform control from the navigation button OnEnter event?

    Here is my structure:

    frmMain --> NavigationSubform --> frmBarcodeEntry --> subfrmBarcodeEntry --> txtBarcodeString

    where txtBarcodeString is the textbox control that I want to set focus for.

  11. #11
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @johanja,
    You do realize you posted to a thread that is almost 5 years old???

    You should have started your own thread, asking your question and referencing this 5 year old thread. You would probably get more responses.

    Good luck.....
    Just sayin........

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Focus in web browser control
    By bjornhe in forum Access
    Replies: 0
    Last Post: 10-27-2011, 05:10 AM
  2. Focus on Key Control
    By windwardmi in forum Access
    Replies: 1
    Last Post: 09-07-2011, 04:57 PM
  3. How to control a button when it has focus
    By shubhamgandhi in forum Programming
    Replies: 2
    Last Post: 07-28-2011, 03:18 PM
  4. Replies: 0
    Last Post: 04-11-2011, 01:39 PM
  5. Maintaining Control Focus
    By sabbo64 in forum Programming
    Replies: 3
    Last Post: 08-18-2009, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums