February 11, 2015 at 11:30 am
I have a control on a subform with the following code
Private Sub Project_Name_DB_Key_Cbo_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 9 Then 'It's a Tabkey
If Shift = 1 Then ' It's a ShiftTab. Move backward in the tab order of the main from
Parent.Applicant_Cbo.SetFocus
Else ' It's a forward tab. Move to the next control in the tab order of the main from
Parent.Regulatory_Sector_DB_Key.SetFocus
End If
End If
End Sub
on a Tab keypress (the else) condition, focus quickly moves to Regulatory_Sector_DB_Key and then on to the next control in the tab order. A similar thing happens on a ShiftTab keypress - focus goes to Application_Cbo and then on to the previous control in the tab order.
I've tried variations of the naming convention for the control e.g.
- Me.Parent.
- Me.Parent!
all have the same behavior.
If anyone has any ideas about how to prevent this unwanted behavior I'd appreciate a pointer.
Thanks in advance.
February 11, 2015 at 3:40 pm
I've also tried the DoCmd.GoToControl ("Regulatory_Sector_DB_Key")
The behavior is the same... 🙁
February 12, 2015 at 7:19 am
I think you need to use the Forms!FormName.ControlName syntax or the Me.Parent.ControlName syntax to get the desired behavior. Tab key behavior when you are using subforms and want to get back to the main form is always a tricky thing.
Wendell
Colorful Colorado
You can't see the view if you don't climb the mountain!
February 17, 2015 at 8:05 am
I'm so glad to finally have some knowledge to contribute back to the forum!
The answer to this problem is that the key press, in this case a tab key (or back tab) is being passed on to the control which receives focus, resulting in the tab being executed on the . So, my solution is simply to change the KeyCode to some other value (not exactly sure what it should be yet - I used 0, but I'm not sure if that's the right code to use).
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply