VBA: Activate text box in non-modal user form - vba

I have a simple UserForm containing a prompt, TextInput and 2 buttons (ok & cancel). I want the text input box to be activated when the UserForm opens so that the user can type directly in the box, without having to click there with the mouse first of all. I have looked at this answer:
VBA Make a text box in a UserForm Active when the UserForm activates?
and set the TabIndex of the TextInput to 0.
I have also tried including the line NumericBox.SetFocus to the initialize code. When I set ShowModal to True for the form, both options give the desired outcome, but I really want the form not to be modal. When I set ShowModal to False, the text box is selected (if I hit enter or tab, the selection moves to the OK button (TabIndex 1)), but I can't type straight away in the InputBox - I still need to click with the mouse in the box first.
Is there anyway I can directly type into the input box of a non-modal form as soon as it is opened?
Thanks

Related

Can an OLEobjects textbox be Visible but not editable?

I have certain command buttons on a WorkSheet that I want hidden until a password is entered.
I do this by having an OLEobjects textbox cover them.
The textbox is called "HideButtons" and, when visible, covers certain command buttons.
The textbox has no border and is the same colour as the background.
To see the command buttons, a password is entered and I change the textbox visibility to False.
`ActiveSheet.OLEObjects("HideButtons").Visible = True
ActiveSheet.OLEObjects("HideButtons").Visible = False`
The WorkSheet is protected to ensure users only have access to certain cells and buttons.
When 'HideButtons' is visible, and the command buttons beneath it are hidden 'HideButtons' can still have text entered in to it.
Is there any way I can prevent users entering text into the 'HideButtons' textbox?

Validation on textbox VBA Word prevents button click executing

I am working on a Word template that has 5 text boxes on a user form (frmMain).
I have a validation routine for each text box, that checks if the correct format is used (i.e. date format in one text box, only allowing the use of numeric values in another, preventing all text boxes left empty and so on). One of my text boxes is called txtNumber.
As of now, one of the validation sub routine fires on txtNumber_Exit.
I also have a command button (cmdHelp) on the same user form that, when clicked, fires the sub routine that shows another user form (frmHelp) that contains a help text on how to use this template.
My problem is that when I click this command button (cmdHelp), the validation routine for the text box "txtNumber" fires. Hence I am stuck with a message (written by me) in a msgbox that says "Number can not be blank", and the frmHelp is not showing.
After this, none of my text boxes have the focus, but my cmdHelp button does.
So if I click the cmdHelp button now, the frmHelp is correctly showing.
But this is messing up the workflow, making the visual experience a bit fuzzy for the user, given the fact that the user gets unnecessary info on invalid input in the txtNumber text box, and that the user needs to click twice on the cmdHelp button.
How can I avoid this?

Access form VBA ComboBox click event

I have Access form with comboboxes, textboxes and buttons. In the comboboxes I have the LimitToList property set to false, because in some situations I need to add some texto, and because of that, I need to validate the content of the comboxes and I'm using the OnClick event.
However if I change the text in the combobox and the click on the "Exit" or "New" button, it fires the OnClick event.
I would like to know if it's possible to the OnClick event only fires when I really click on a line of the combobox or press the Enter key, instead of firing when I click other button after changing the texto of the combobox.
Thanks :)
You can set your validation on update property of combo box. So whenever you change your combo box content it automatically checks for the validation.

How do you add a help button to Excel userform

I have a few different userforms in Excel 2007 right now and was wondering if I could add a "?" button next to the close symbol in the userform.
Alternatively, is there a way to display some text when I hover over a specific label
The form property "WhatsThisButton" displays the question mark icon next to the close button, but this does nothing without creating an actual help file and assigning it to your form, this is not an easy thing to do. Far easier is to display text as you have described, each control has a "controlTipText" property that will display whatever text you enter in there, when your user hovers their mouse over the control

Program does not tab through controls in the correct order

I have a form with a button which adds text boxes in addition to the 8 text boxes already on the form which are named Textbox1 through 8. When I launch the application and enter the first textbox, I can tab through all the way from 1 - 8.
When I click my button it programmatically creates a textbox below the last textbox with appropriate name such as Textbox9 for the ninth, Textbox10 for the tenth etc.
However when a textbox is added via the button, tabbing through the controls skips from the eighth, to any buttons on the form, and then to the created textbox. Any idea why this happens and how I can resolve it? I've tried google to no avail. Please let me know if you need any code, thank you.
Thanks to Daniel Cook and Grim, I solved my issue by setting the tabindex to match the textbox number, however I also found that setting TabStop to false on the buttons and controls helped me to keep the tab focus within the text boxes.