KolGuyXcel
Board Regular
- Joined
- Jun 29, 2018
- Messages
- 147
In a UserForm, there are ComboBox1, ComboBox2 and TextBox1 with TabIndex set as 0, 1 and 2 respectively. TabStop is set to True for all. Only the AfterUpdate event for each of the ComboBoxes and the TextBox is defined and each one has a debug.print statement. When the UserForm is initialised, the immediate window is blank, but the boxes are correctly filled with relevant data reading from the relevant sheet with the Immediate Window blank. The focus (cursor blinking) is also on ComboBox1, as expected. When the Return Key is hit (without modifying anything in ComboBox1), the debug.print for ComboBox1 is getting executed in the Immediate Window and the focus shifts to ComboBox2 (text in ComboBox2 getting selected, though no code is written for that). Now when the Return Key is hit (without modifying anything in ComboBox2), the debug.print for ComboBox2_AfterUpdate is not getting executed, the Immediate Window is showing only debug.print of ComboBox1_AfterUpdate, and the focus shifts to TextBox1. The same is happening with TextBox1 i.e. if the Return Key is hit without modifying anything in TextBox1, the debug.print in TextBox1_AfterUpdate is not getting executed, the Immediate Window is still showing the execution of debug.print of only ComboBox1_AfterUpdate and the focus shifts to the "next" button. Shift+Return is also navigating the cursor in the UserForm as expected so are Tab and Shift+Tab, but none are executing the debug.print for the ComboBox2 and TextBox1. Even the debug.print in ComboBox1 is getting executed only the first time and not for subsequent changes of focus (in case someone intends to play around navigating the boxes using Shift, Tab and Return Keys). The AfterUpdate events are all getting executed when at least any one key other than Tab and Return Key (BackSpace, Delete etc.) is hit.
I need to trigger these AfterUpdate events even when nothing is getting modified or no other key is hit in either of the ComboBoxes or the TextBox.
What am I missing? Or do I have to resort to the KeyDown event (I would then have to deal with combinations of Shift Key, Tab Key and Return Key)?
I need to trigger these AfterUpdate events even when nothing is getting modified or no other key is hit in either of the ComboBoxes or the TextBox.
What am I missing? Or do I have to resort to the KeyDown event (I would then have to deal with combinations of Shift Key, Tab Key and Return Key)?