Results 1 to 5 of 5

Thread: Focus (2000)

  1. #1
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Focus (2000)

    Hi,

    I have list box (list 16)as search result after user enter criteria to search. I put the code (List16.SetFocus) after the code for search, so user can press TAB to get the detail information of the result by keydown function. Also I put the code (List16.Visible = False; lblNoRecords.Visible = True; lblNoRecords.Caption = "No records matching the criteria you chose, please try it again!"), so if no record in db is match the cirteria that user enter, List 16 will display and a message will pops up.

    But I got a message (You can't hide a control that has the focus) if no record in db is match the criteria that user enter. My question is what other opinions I have beside use setfocus so I still can get what I want without any error message.

    Regards.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Focus (2000)

    If you want to hide the list box, you must first move the focus to another (non-hidden) control; you can then set the Visible property to False.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Focus (2000)

    Thanks, Hans.

    But can you provide more detail how to move the focus to another (non-hidden).

    Regards

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Focus (2000)

    You'll have to decide which control is suitable - I can't tell you that. Say it is named MyControl. Insert the line

    Me.MyControl.SetFocus

    immediately above the line

    Me.List16.Visible = False

  5. #5
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Focus (2000)

    Thanks, Hans.

    It works!!!

    Regards!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •