I have a textbox that collects one or more item numbers from the user. After each entry, a subroutine is run which I call from textBox_AfterUpdate.
When the user is done entering items, I need control to shift to a commandButton which runs another routine.
I've been able to construct code that allows 1 textbox item and then shifts to the commandButton but then the user has to arrow or mouse back to the textbox to enter the next item and if they inadvertently hit Enter, the program continues and they have to start over.
I can also keep focus in the textbox by setting Cancel = True in Textbox_Exit but then I can never get out of the textbox to run the code from the command button.
Can anyone suggest how I can repeat <input item, run subroutine1> until done entering items and then move on to commandButton which runs subroutine2?
I've tried setting Multiline and EnterKeyBehavior in the textbox properties to true and I can enter multiple values in the textbox, but then sub 1 is not run.
Here are some excerpts from my code:
Private Sub TxtNum_AfterUpdate()
cmdAdd
End Sub
Private Sub TxtNum_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = True 'keeps focus here always, without this
'control goes to command button
End Sub
Private Sub cmdAdd()
<code for Sub 1>
End Sub
Private Sub cmdBuild_Click()
<Attached to cmdButton -- code for Sub 2>
End Sub
Thank you so much to anyone who has any advice.
Regards,
Marcia
When the user is done entering items, I need control to shift to a commandButton which runs another routine.
I've been able to construct code that allows 1 textbox item and then shifts to the commandButton but then the user has to arrow or mouse back to the textbox to enter the next item and if they inadvertently hit Enter, the program continues and they have to start over.
I can also keep focus in the textbox by setting Cancel = True in Textbox_Exit but then I can never get out of the textbox to run the code from the command button.
Can anyone suggest how I can repeat <input item, run subroutine1> until done entering items and then move on to commandButton which runs subroutine2?
I've tried setting Multiline and EnterKeyBehavior in the textbox properties to true and I can enter multiple values in the textbox, but then sub 1 is not run.
Here are some excerpts from my code:
Private Sub TxtNum_AfterUpdate()
cmdAdd
End Sub
Private Sub TxtNum_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = True 'keeps focus here always, without this
'control goes to command button
End Sub
Private Sub cmdAdd()
<code for Sub 1>
End Sub
Private Sub cmdBuild_Click()
<Attached to cmdButton -- code for Sub 2>
End Sub
Thank you so much to anyone who has any advice.
Regards,
Marcia