Tab Key Behavior

mafhobb

Registered User.
Local time
Today, 12:45
Joined
Feb 28, 2006
Messages
1,249
How could the Tab Key behavior be changed so pressing it does nothing on a specific subform?

Mafhobb
 
Dave,
I'm not sure that would work because you would still exit the SubForm. How about eating it during a KeyPress event?
 
Well, that's what I though, but even after doing this, if I am on a field (the last one on a subform) and press tab, it moves on to the next record of that field, which is a blank record. This causes some problems that I want to avoid...
So how can I prevent that TAB key from causing the move to the next (new) record?

mafhobb
 
Hi RuralGuy. I did not see your post earlier.

How would I identify the TAB key in the code and what would I do once it is identified. Would it be something like If key=TAB then exit?

thanks in advance
 
Well, that's what I though, but even after doing this, if I am on a field (the last one on a subform) and press tab, it moves on to the next record of that field, which is a blank record. This causes some problems that I want to avoid...
So how can I prevent that TAB key from causing the move to the next (new) record?

mafhobb
That one is easy. Go to the "Other" tab of the property sheet and change the Cycle property.
 
I feel pretty dumb right now....Thanks again RuralGuy

mafhobb
 
Hi RuralGuy. I did not see your post earlier.

How would I identify the TAB key in the code and what would I do once it is identified. Would it be something like If key=TAB then exit?

thanks in advance
It would be in the KeyDown event and look something like:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = vbKeyTab Then
        KeyCode = 0
    End If
    
End Sub
Warning <<< AIR CODE >>>
 
probably, but i dont think you can tab out of a subform, tbh
 
probably, but i dont think you can tab out of a subform, tbh

You can easily enough (I've done this trick many times) as long as it isn't a datasheet -

Put a text box on the subform and set it in the tab order to be just after the last control you want to move back to the main form. Size it to something like .01" and in the got focus event put your code which redirects it to the main form control.

But, like I said, that only works for a single or continuous form subform. A datasheet it won't work with because the column needs to be visible for the control to get focus and then that kind of messes up the view.
 

Users who are viewing this thread

Back
Top Bottom