Lost Focus Event (1 Viewer)

LanaR

Member
Local time
Tomorrow, 02:01
Joined
May 20, 2021
Messages
113
I'm currently creating a pseudo combo box. The aim being to create a combo box that has a more flexible search.

I'm using an unbound text box and button with an unbound list box (populated using data input into the text box, it's row source being a query that uses a Like "*" & [me.textbox] & "*" criteria to search any part of the data) to simulate the dropdown. I've got everything working pretty much as I want. However, I have found a hurdle when it comes to detecting when focus has moved from the group to another control. I've tried using the Lost Focus event to test which control has focus, the issue here is that that simply returns the name of the control to which the event belongs. My next thought was to use the Got Focus events of other controls on the form to test if the list box is visible and hide it if so.

That would certainly work, but becomes rather tedious if you have more than a couple of additional control on the form. Is there another method I could use to hide the list box once the user has finished with it?
 

Attachments

  • Psueudo Drop Down with Improved Search.accdb
    3 MB · Views: 89

MarkK

bit cruncher
Local time
Today, 09:01
Joined
Mar 17, 2004
Messages
8,181
Here's a way you can do this with a class module, and a regular combobox....
 

Attachments

  • SmartComboExample.accdb
    600 KB · Views: 114

moke123

AWF VIP
Local time
Today, 12:01
Joined
Jan 11, 2013
Messages
3,920
just a thought

Code:
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Me.List5.Visible Then Me.List5.Visible = False

End Sub
Just make sure there is no space between the button and list
 

Users who are viewing this thread

Top Bottom