Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    845

    Opening form focus

    How do you set focus on a popup form when opening access?



    IE: Double click on the access Icon, the popup form opens. I have to use the mouse to select the form before I can input data. If I select form, input data, then select a report (Command Button VAB close form, open report), the focus goes to the report. I then close the report and open the form (Command button VBA close report, open form), the focus goes to the form.

    I am looking to get focus on the form

    Code:
    Public Sub Form_Load()
    DoCmd.RunCommand acCmdAppMinimize
    End Sub
    I tried using:
    Me.Myfield.SetFocus
    Forms![MyForm]![MyField].SetFocus in the Form_Load and Form_Activate, Form_LostFocus, Form_GotFocus


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    I tested this and I see it does not work. Don't know if it can. I seldom use popup form. Why would initial form need to be popup?
    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
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    845
    June7,
    Its only 2 pieces of information for the user. Didn't see the need to have a full white screen for it. A small popup is suffucient.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    Ah, I don't use Tabbed Documents, I prefer Overlapping Windows. I can make forms whatever size I want.
    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
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    Am I missing something here?
    It works for me whether you use tabbed documents or overlapping windows.
    See attached very simple example.
    It has a popup start form with 2 textboxes.
    Focus goes automatically to the first textbox in the tab order
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    I disabled your code to set value of unbound control and control does not get focus. Tried the SetFocus and it does nothing.

    Seems form and control do not get focus unless clicked or control's value set with code.
    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
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    That's not my experience
    In fact I originally uploaded a file with a form with just one textbox and no code before replacing with the user name / password form.
    I'm uploading the original version again now.
    Focus still goes to the textbox for me.
    In fact that happens even if its in a non-trusted location so the security bar appears

    Perhaps your client settings are somehow different to mine?
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    Colin, you have this form set to open by default when db opens? That's the issue as I understand it. Default form set as popup does not get focus when db first opens.
    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.

  9. #9
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    As already stated, it always works for me.
    In fact many of my example and commercial apps include this 'feature' both using standard forms and popups.
    The v1 file doesn't seem to have been downloaded.
    Suggest you try that one as well. If it doesn't work first time, close and reopen.
    If that still doesn't work for you, I think there must be a difference in our settings
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    Okay, finally figured out what I was doing wrong with my db. I set form as popup and default then just ran C&R, did not close file. Form opened but did not get focus. I reversed settings and ran C&R again to restore so I never closed file with the popup/default settings. Have to actually close then form gets focus when opening.

    Since OP has certainly closed and reopened file numerous times, still a mystery why it fails.
    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.

  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    Not sure I understood that.
    It still returns to the startup form after C&R and the first control in the tab order still gets focus.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    After changing settings with my existing form, just running C&R wasn't good enough. I had to close db. However, now I am testing with other forms. C&R is enough. Now back to the first form. All work when set as default form and run C&R. This is too weird. It definitely was not working with my very first attempt yesterday.
    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.

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,819
    Works for me too. Can set focus to any one of 3 textboxes on a popup form and still works if it's modal. The fact that for testing purposes they are not bound shouldn't matter.
    BTW - if you specify a small size for a popup when forms are tabbed, the smaller size prevails.
    Maybe best if OP posts copy of db.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    845
    I tried the test form and it does work. I am running this on startup
    Code:
    Public Sub Form_Load()
    DoCmd.RunCommand acCmdAppMinimize
    End Sub
    Battery V2.zip

    I think the report is taking the focus.

  15. #15
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    All that code does is minimise the application to the task bar which is pointless in my opinion
    Remove that code from Form load and it works perfectly.

    The report is irrelevant to this issue but also remove the same code line from the report.
    See attached
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Set focus to another form
    By aytee111 in forum Programming
    Replies: 19
    Last Post: 11-01-2015, 01:40 PM
  2. Replies: 5
    Last Post: 01-24-2015, 12:59 AM
  3. Set focus in sub form
    By Derrick T. Davidson in forum Forms
    Replies: 7
    Last Post: 08-15-2014, 08:18 AM
  4. Opening a report and setting focus to it
    By Kirtap in forum Programming
    Replies: 2
    Last Post: 02-19-2014, 12:05 PM
  5. Replies: 1
    Last Post: 02-29-2012, 09:38 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