Results 1 to 4 of 4
  1. #1
    jpadeutsch is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Nov 2015
    Posts
    8

    ListBox Click event problem. Focus unexpectedly moving to different ListBox

    I have a form with three listboxes on it. If the second or third listbox has focus and I select an item by clicking on it or by using the up or down arrow keys, it selects the new item correctly in the onClick event, but then focus always moves to the first of the three listboxes. This is ok when I am clicking with the mouse, but if I am using the up or down keys subsequent presses move the selection in the first listbox instead of the one that I was previously in.



    I have tried to SetFocus to the listbox I want in its own OnClick routine, but focus still moves to the first listbox on the form.

    Can anyone suggest how I can keep focus where I want it? The only alternative is to ignore keystrokes on this form and only allow selection with the mouse. This would not be too bad as these listboxes do not contain many items and there is not really any reason to step through the items rather than finding and clicking the one I need.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    My guess is that you're requerying something. If that doesn't help, would need to see code. Since there's probably several events you've coded for, might be simpler if you just uploaded a compacted and zipped db copy.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    jpadeutsch is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Nov 2015
    Posts
    8

    Thumbs up Brilliant. Thank you a million times

    Quote Originally Posted by Micron View Post
    My guess is that you're requerying something. If that doesn't help, would need to see code. Since there's probably several events you've coded for, might be simpler if you just uploaded a compacted and zipped db copy.
    Thank you very much for reply and your interest. You have hit the nail on the head. These list boxes are used to select the filter and sort order for the required subset of the data in the table. So each time the selection changes, the record set for the form is rebuilt with a new SQL command. This presumably does the requery as part of its action. I have now inserted a call to SetFocus on retjrn from the routine which rebuilds the record set, and all now works.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    This presumably does the requery as part of its action.
    That would be correct. Glad I could help & good luck with your db.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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. Replies: 2
    Last Post: 10-09-2016, 05:41 PM
  3. Replies: 13
    Last Post: 09-10-2015, 03:37 PM
  4. Replies: 4
    Last Post: 06-24-2013, 07:34 AM
  5. Replies: 1
    Last Post: 09-10-2012, 11:21 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