Results 1 to 5 of 5
  1. #1
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78

    Click out to lose focus

    I have text field that expands when it has the focus and then will go back to its original size on lose focus.

    This works fine as long as the user tabs out of the field, but if they just click outside the field, the field stays expanded.



    Is there any way to change that?

    I have Auto Tab set to Yes (no difference with it set to NO)
    Tab stop is Yes
    GotFocus event changes the width and height of the text box
    LostFocus event changes width and height to its normal size

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    As long as whatever is being clicked on can take the focus, the control loses the focus so your even should run. Put a break point on it and see if it runs when focus is lost when this click action you mention takes place. Then step through (F8) and watch how the code executes. If it's because of some condition you're testing for, you can fix that. If the event doesn't fire, go to the Event tab in property sheet and ensure the event is set there. If still no joy I'd try replacing the control with a new one.
    Last edited by Micron; 04-01-2022 at 08:43 AM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78
    Quote Originally Posted by Micron View Post
    As long as whatever is being clicked on can take the focus, the control loses the focus so your even should run. Put a break point on it and see if it runs when focus is lost when this click action you mention takes place. Then step through (F8) and watch how the code executes. If it's because of some condition you're testing for, you can fix that. If the event doesn't fire, go to the Event tab in property sheet and ensure the event is set there. If still no joy I'd try replacing the control with a new one.
    It appears that it needs a focus somewhere, anywhere, to actually lose focus. So by someone simply clicking out of the text field doesn't actually lose focus.

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    but if they just click outside the field, the field stays expanded.
    So what is the "somewhere" that doesn't allow the focus to shift? Perhaps you need to move your code to either MouseUp or MouseDown events instead, or one of each. Up for expanding, down for shrinking. Could work with one of those events too.

    If you want to post a zipped db copy for analysis, perhaps follow the instructions given by clicking on the "how to attach files" button at the top of the forum page.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Try adding the code that shrinks the textbox to the Detail_Click event. There isn't a focus event for the Detail section
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

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

Similar Threads

  1. Replies: 3
    Last Post: 10-07-2020, 06:14 AM
  2. Need to lose focus on a button on a sub form.
    By TenOc in forum Programming
    Replies: 1
    Last Post: 03-29-2019, 04:16 PM
  3. Alt-Tab makes popup form lose focus
    By keviny04 in forum Forms
    Replies: 4
    Last Post: 04-21-2015, 10:38 AM
  4. Verifing Data in a text box when it lose focus...
    By hswilliams2525 in forum Access
    Replies: 1
    Last Post: 01-17-2012, 08:36 PM
  5. Update Database on Lose Focus event
    By sgroth in forum Forms
    Replies: 2
    Last Post: 06-11-2011, 07:31 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