using tabindex in VBA to control what gets focus

Coxylaad

New member
Local time
Today, 15:22
Joined
Jan 11, 2022
Messages
21
Hello again,
Looking for a bit of advice, I am building a filter panel at the top of my form to filter the results displayed on the form. I have 3 or 4 textboxes. I am using the 'on exit' event to trigger the filter code to build and apply the filters, and its working, however its not moving to the next textbox in the tabindex so the cursor ends up stuck in the current textbox.

I was looking stick a bit of code that read the tabindex of the current textbox, added 1 to it, then set the focus to the object with the next tabindex.

Does that make sense? ie everytime you tab out of the textbox it runs the apply filter code.

I dont want to do anything long winded only to find out its a setting or something!

thanks

Ian
 
Hi. Did you say you're using the Exit event? If so, wouldn't it fire when you tab out of the Textbox? Otherwise, how are you getting the event to fire? I would probably use the AfterUpdate event myself.
 
yes it does fire when i exit the textbox, but what happens is the code runs and something makes the focus stay on the current textbox and not move to the next one
 
ive managed to get it working, so I changed the even to 'onkeypress' put this in it

Private Sub fltrEstimateID_KeyPress(KeyAscii As Integer)
If KeyAscii = 9 Then
Call btnfltr_Click
End If
End Sub

so it checks for the tab key being pressed, (09) and it runs the filter code when it detects it.
the weird thing is the tab keypress is registered in the destination textbox, not the one that I have just input my filter string into, which actually makes the job easier as I dont have to bother with setting the focus to the next textbox.
 
Looking for a bit of advice, I am building a filter panel at the top of my form to filter the results displayed on the form. I have 3 or 4 textboxes.
I always use a ribbon form with the main fields of the table/query
1 -the headers are fully visible (multi-line)
2 -green search fields strictly above the data fields
3 -you can set the selection conditions in any combination, usually equality, Like(contains) or interval
4 -I don't let the user mess up something (yellow fields are closed from correction)
5 -when clicking on the selected line, a link to the selected entry of the subordinate form is returned
 

Attachments

  • poisk0302.png
    poisk0302.png
    33.5 KB · Views: 296
ive managed to get it working, so I changed the even to 'onkeypress' put this in it

Private Sub fltrEstimateID_KeyPress(KeyAscii As Integer)
If KeyAscii = 9 Then
Call btnfltr_Click
End If
End Sub

so it checks for the tab key being pressed, (09) and it runs the filter code when it detects it.
the weird thing is the tab keypress is registered in the destination textbox, not the one that I have just input my filter string into, which actually makes the job easier as I dont have to bother with setting the focus to the next textbox.
Hi. Glad to hear you got it sorted out. Good luck with your project.
 
thanks, so far access has allowed me to speed up the development of this project. I was originally using .net but access is so much more user friendly.
 
I always use a ribbon form with the main fields of the table/query
1 -the headers are fully visible (multi-line)
2 -green search fields strictly above the data fields
3 -you can set the selection conditions in any combination, usually equality, Like(contains) or interval
4 -I don't let the user mess up something (yellow fields are closed from correction)
5 -when clicking on the selected line, a link to the selected entry of the subordinate form is returned
this looks exactly like what I am trying to build - where abouts is the ribbon form!?!
 

Users who are viewing this thread

Back
Top Bottom