"Activation" versus SetFocus for Userform controls

kz9yyc

New Member
Joined
Aug 4, 2007
Messages
11
Hello All,

Here is some background information:
1. I use Excel 2007.
2. I am a novice coder. I apologize upfront for any ignorant questions.
3. I don't know if I can paste userform pictures. I would be happy to email my spreadsheet macro to anyone who wishes to see it.
4. My userform is a multipage control that covers 90% of the form. A frame ("Frame1") covers the other 10%, but does not reside within the multipage. "Page 1" of the multipage contains approximately 77 controls--labels, Listbox, Combobox, and CommandButtons.

I have two goals:
1. I want to write code that results in a visible cursor within a Combobox. Consequently, one may utilize arrow keys to scroll up and down within the Combobox without having to mouse-click within the Combobox. Also, I don't want focus to leave the Combobox. Sometimes, when I scrow down using an arrow key, focus goes to another control.
2. I want arrow key actuation to mimic "Commandbutton_click" events. The userform is a process-specific, troubleshooting flowsheet that walks an operator through a series of questions and actions. For some processes, there are over 50 steps that an operator may cycle through. Instead of clicking on a "GotoNext" button 50 times, I want to reliably use arrow keys.

I have the following problems:
1. When I "SetFocus" to the Combobox, I cannot see a blinking cursor. Nonetheless, sometimes I can scroll within the Combobox using arrow keys. Other times, pressing arrow keys results in the "focus" changing to other controls. Ultimately, I eventually cannot even see where the focus is. Excel "Help" states the following: "By default, setting the focus to a control does not activate the control's window or place it on top of other controls." Alrighty then, how do I "activate" a Combobox that results the cursor within the Combobox, as if I actually mouse-clicked the Combobox?
2. When I utilize arrow keys to actuate a CommandButton, sometimes it doesn't work (i.e., focus goes somewhere else):
- I've utilize "Frame1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)."
- I set focus to Frame1. I did this because it seems less likely to lose focus than controls on Page 1.
- On all userform controls, I've set "TabStop = False" and "TakeControl******* = False".

I appreciate your help and patience!!

Regards,
John
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Watch MrExcel Video

Forum statistics

Threads
1,123,057
Messages
5,599,550
Members
414,316
Latest member
ExcelLee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top