Finding the control that was about to gain focus

Erik100

New member
Local time
Today, 12:06
Joined
Oct 2, 2016
Messages
2
I have a form with a searching tool in the header. The user can write in textboxes (one for each field in the query) and hit the "search" button to filter. However, I wanted the search to begin everytime a textbox is edited (without clicking the search button).

Altough I achieved that, the problem is the following : the requery that happen while exitting a control prevents the next control to gain focus.

Any idea how to go to that other control the user was trying to go ? I already found a way to get the next control in the Tab Index order, but what if the user clicked somewhere instead of tabbing ?
 
You shouldn't. What if the user needs to fill more than 1 box?
But if you are ONLY using 1 box , have ALL text boxes AFTERUPDATE event run the search.
 
Thanks Ranman for your reply. However, this does not solve the issue. With your solution, this is what happens :
- The requery launch perfectly
- The focus remains on the edited textbox (this is not the desired behavior, and I guess this happens because when the requery is launch - by the AfterUpdate event - this interrupts the action of gaining focus)

As I said, I achieved the requery part and this works fine : the VBA code handles perfectly that the user can use all/part/one/none of the textboxes. But putting the VBA code in AfterUpdate/LostFocus/Exit of those textboxes seems to interrupt the "focus changing" part, and after the criterion change is managed, the active control is not the one the user should expect.
 

Users who are viewing this thread

Back
Top Bottom