Results 1 to 9 of 9
  1. #1
    jmoore is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    4

    moving between subforms using wrong event?

    I have a mainform with 5 subforms in Access 2007. The Cycle property for all forms is set to Current Record. In the first 4 subforms I created an unbound textbox at the end of the tab order and placed code (sample below) in the On Got Focus event to move from one subform to the next. It works fine as long as the user does not try to use the mouse to go back to a previous subform. Sometimes it appears that the previous subform is disabled as nothing happens when clicking on any of the textboxes. Other times I receive a run-time error 2110, "Microsoft Office Access can't move the focus to the control {last subform name}.

    Private Sub Text32_GotFocus()
    Parent.qProgressPlan.SetFocus
    Parent.qProgressPlan.Form!WorkplanComp.SetFocus
    End Sub

    One other note: Using the mouse I can move between subforms to my heart's content and edit any textbox. Do I have the code in the wrong event? Or is my code incorrect. Do I need to clear the focus somehow after entering the texbox? Thanks in advance for any assistance.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,009
    Set focus to the page of tab control, not the subform on it. Cursor will rest in the first active control on the tab page.

    I have never used the Parent qualifier. Just tried and doesn't seem to work for me. I would use Forms!mainformname.pagename.SetFocus
    or
    Form_mainformname.pagename.SetFocus

    The second example will provoke intellisense popups.
    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
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by June7 View Post
    I have never used the Parent qualifier. Just tried and doesn't seem to work for me. I would use Forms!mainformname.pagename.SetFocus
    Parent is actually a good thing to use instead of the full qualified form path using Forms!....

    But you have to use

    Me.Parent.PageName.SetFocus

    not just

    Parent.PageName.SetFocus

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,009
    Tried that, Bob. Would be nice if it provoked intellisense popups but not seeing that.
    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
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Which intellisense aren't you getting? It does do intellisense but it is limited in what it displays, just like the intellisense on a subform control can display some things about the subform but not the controls in there.

    But I use Me.Parent a lot and it works fine for me. And it saves you having to code in the name directly which means you can reuse code sometimes without having to go make changes.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,009
    Nothing pops up after the second dot of Me.Parent. - Parent shows in the popup after Me. but nothing after Parent. - I was expecting the tab page names as with the other syntax but get nothing. I am testing this code behind a subform that is on a tab control and I have the main form in design view.
    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
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Yeah, it doesn't. It is a bummer but it does work but you have to type in the other parts correctly.

  8. #8
    jmoore is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    4
    Thanks for everyone's suggestions, however I am still having the same problem. I am not using Tab pages. All of the subforms are on one mainform. When the user moves from one subform to the next with the tab key, the previous subform(s) appear to be disabled. No edits can be made, nor can they select the textbox. Any other suggestions, please?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,009
    Okay, sorry for that assumption. I just tested this concept and getting the same issue. I set a breakpoint on the SetFocus line and I find that when I click back into the first subform the textbox GotFocus event fires, so am forwarded to the next form again. I changed to the Enter event for the textbox and that worked better.
    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.

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

Similar Threads

  1. What's wrong!
    By khalid in forum Programming
    Replies: 15
    Last Post: 06-27-2011, 06:38 AM
  2. What is wrong with this IFF?
    By bburton in forum Reports
    Replies: 2
    Last Post: 03-16-2011, 10:42 AM
  3. Replies: 5
    Last Post: 02-08-2011, 11:17 AM
  4. Moving from vs 07 to vs 97
    By Kilroy2.0 in forum Access
    Replies: 4
    Last Post: 06-04-2010, 08:42 AM
  5. What am I doing wrong?
    By brandon in forum Access
    Replies: 2
    Last Post: 08-03-2008, 10:26 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 - Senior Forums