Results 1 to 7 of 7
  1. #1
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67

    Moving focus out of the subform

    Hi all,



    I have a subform on my main form. There is a button on the footer of my subform called cmdAdd. I use this button to open an unbound form form which i use to write data into the underlying table of the subform. This is the only object on the subform that can get focus. Everything else is either disabled, locked or invisible.

    The current event of the main form disables this button based on the current record on the main form. The problem is that I can not move the focus away from this button so that it is disabled. I have the forms On-load event to move the focus to a button on the main form. Then it works, but when I navigate between record on the main form, and have to use this button on the sub-form, then it gets the focus again, and then main forms current event can't disable it. Is there an event procedure that I can use to move the focus from this button to something on the main form when I navigate between records. Maybe something like when the master field value changes or the parent record changes.

    Thanks in advance.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Instead of OnLoad, try the OnCurrent event of the main form.
    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
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67
    But how can I move the focus out of a subform using the main forms current event. the Me.ControlName.SetFocus isn't going to do it. It will move the focus that is on the main form to that particular control. The subform will have its own focus set somewhere, that can be moved out of the subform from within the subform. Unless I am mistaken, this has been my experience.

    In the case of a main form with a subform, I always have two focuses set. One on the subform and one on the main form. Unless the focus is moved out of the subform with some code from within the subform.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Guess I won't be much help. As far as I know there can be only one focus at a time. Each SetFocus command superseding any previous, regardless of where or when executed.
    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
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67
    Thanks for suggestion though. I don't know, it makes sense for there being only focus set somewhere. I have a few forms with subforms. In each case, when I open the forms, I have one focus set on a button on the main form, and another one on the subforms only button. I have looked on the internet too. I see a few other posts with similar situation.

    I hope someone can tell me how this is.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Never had an issue with this so never thought about it.

    Something else to consider. Do you really need the button to be on the subform? Why not just put it on the main form? I have used this approach.
    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
    Put a text box on the form and size it to .01" x .01" and set the border to transparent. You can then set the focus there but it should not be able to be seen.

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

Similar Threads

  1. Replies: 2
    Last Post: 06-17-2011, 04:26 PM
  2. Replies: 0
    Last Post: 04-11-2011, 01:39 PM
  3. Set focus to a field on a subform
    By MiaAccess in forum Forms
    Replies: 11
    Last Post: 03-05-2011, 11:49 AM
  4. Passing focus to subform.....
    By smorelandii in forum Forms
    Replies: 3
    Last Post: 02-04-2011, 10:51 AM
  5. Replies: 15
    Last Post: 11-09-2010, 04:27 PM

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