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