Results 1 to 4 of 4
  1. #1
    Axeia is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2011
    Posts
    16

    Requery without losing focus?

    I have a form with an unbound textbox and to this textbox I've added some VBA code that requeries the form on change. This way the user can quickly find what they're after.

    There is one little problem with this, the requery on the form makes the textbox lose focus, the focus is placed on the first bound textbox of the form. I tried working around this by calling setFocus on the unbound textbox, but this also selects all text in it! So if you're typing you keep overwriting what you previously typed.

    Screenshot shows the code and form.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Check out SelStart in VBA help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Axeia is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2011
    Posts
    16
    Not sure what you meant with "VBA help" (No sticky or subforum by that name) but SelStart does the trick.
    Code:
        Me.tbTitel.SetFocus
        Me.tbTitel.SelStart = Len(Me.tbTitel)
    Thank you.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help. "VBA help" means the help system in the VBA editor.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Losing Records Saved From Form
    By ProgZ in forum Forms
    Replies: 2
    Last Post: 04-17-2011, 11:32 PM
  2. OrderBy Losing Criteria
    By P5C768 in forum Forms
    Replies: 1
    Last Post: 01-21-2011, 01:07 PM
  3. Replies: 15
    Last Post: 11-09-2010, 04:27 PM
  4. tables keep losing primary key
    By lwwilliam in forum Access
    Replies: 1
    Last Post: 10-18-2010, 11:36 AM
  5. Requery?
    By CO711 in forum Forms
    Replies: 0
    Last Post: 08-06-2008, 08:03 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