Results 1 to 3 of 3
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    hide a list box on lost focus

    how do i hide a list box when it has lost focus

    on an after update, I use this code:

    Me.txtManufacturer.SetFocus


    Me.lstGoToType_AtType.Visible = False

    it works fine
    __________________________________
    but the user may not update the control; they may simply decide to do 'something' else,n which case, I want the list box to go away

    i thought i could do this:

    Private Sub lstGoToType_AtType_LostFocus()
    Me.lstGoToType_AtType.Visible = False

    or

    Private Sub lstGoToType_AtType_Exit(Cancel As Integer)
    Me.lstGoToType_AtType.Visible = False


    but for one reason or another, it's not the right approach

    thoughts?


    (with thanks in advance)
    mark

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You have to determine under what conditions you want the list box visible. When/why does it become visible??

    Is there a control that could cause/require the list box to be visible? Hide the list box, then make it visible when required.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    As Steve has noted, you need to determine a strategy for making the Listbox Visible, when appropriate; otherwise, how will you ever make a selection from it?

    Is your intention, as is often the case, for it to be remain Visible, until a Selection has been made from it, for a given Record?

    As for making it Invisible, you cannot change the Visibility Property of a Control while it still has Focus, as it does when the LostFocus and OnExit events fire. So the trick is to Set Focus to another Control and then make the target Control Invisible.

    If, as outlined in the the second paragraph, above, you want it Visible unless/until an item has been selected from it, you would need to do something like this:

    Code:
    Private Sub lstGoToType_AtType_Exit(Cancel As Integer)
    
    If Nz(Me.lstGoToType_AtType,"") <> "" Then  
     AnyOtherControl.SetFocus
     lstGoToType_AtType.Visible = False
    Else
     lstGoToType_AtType.Visible = True
    End If
    
    End Sub


    Code:
    Private Sub Form_Current()
     
    If Nz(Me.lstGoToType_AtType, "") <> "" Then
     lstGoToType_AtType.Visible = False
    Else
     lstGoToType_AtType.Visible = True
    End If
    
    End Sub


    You simply need to replace AnyOtherControl, in the line

    AnyOtherControl.SetFocus

    with the name of any other Control on the Form that can receive Focus.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Lost Newbie.....Please help.
    By beachbumch in forum Access
    Replies: 3
    Last Post: 06-26-2012, 10:06 AM
  2. Lost Network
    By chessico in forum Access
    Replies: 0
    Last Post: 08-11-2011, 06:10 AM
  3. Hide The Object List in 07
    By cassidym in forum Database Design
    Replies: 2
    Last Post: 07-13-2010, 02:18 PM
  4. menus are lost
    By eddwads in forum Access
    Replies: 2
    Last Post: 01-08-2010, 08:34 PM
  5. Completly lost...
    By fairytalesrcute in forum Access
    Replies: 1
    Last Post: 05-14-2009, 09:24 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