D
dan dungan
Using Excel 2000, I have a userform--userform1, with a textbox--
txtquantity1.
I'm trying to get the user to enter the quantity for a part number in
a quote. There could possibly be as many as 40 different quantities
requested by the customer.
When the user enters the quantity and presses enter, I'd like to ask
them if they have another quantity to enter, or at least provide
another textbox so they could enter another quantity and keep
generating textboxes until the user is through adding quantities.
When they are finished entering the last quantity, the user needs to
choose the proper formula and then I need to calculate a price based
on. . . Well this part gets complicated.
Right now I just want to see if I can store the quantities for
calculations later.
I'm trying to use the code below, but it doesn't loop and overwrites
the textbox with the next quantity.
Thank you for your feedback.
Private Sub txtQuantity_1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Message, Title, Default, MyValue
Message = "Enter the next quantity" ' Set prompt.
Title = "Quantity" ' Set title.
Default = "" ' Set default.
' Display message, title, and default value.
Dim Msg, Style, Ttle, Help, Ctxt, Response, MyString
Msg = "Do you want to continue ?" ' Define message.
Style = vbYesNo + vbDefaultButton2 ' Define buttons.
Response = MsgBox(Msg, Style, Ttle, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
Set Mycmd = Me.Controls.Add("Forms.TextBox.1", name, True)
MyValue = InputBox(Message, Title, Default)
Mycmd = MyValue
Else ' User chose No.
MyString = "No" ' Perform some action.
End If
End Sub
txtquantity1.
I'm trying to get the user to enter the quantity for a part number in
a quote. There could possibly be as many as 40 different quantities
requested by the customer.
When the user enters the quantity and presses enter, I'd like to ask
them if they have another quantity to enter, or at least provide
another textbox so they could enter another quantity and keep
generating textboxes until the user is through adding quantities.
When they are finished entering the last quantity, the user needs to
choose the proper formula and then I need to calculate a price based
on. . . Well this part gets complicated.
Right now I just want to see if I can store the quantities for
calculations later.
I'm trying to use the code below, but it doesn't loop and overwrites
the textbox with the next quantity.
Thank you for your feedback.
Private Sub txtQuantity_1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Message, Title, Default, MyValue
Message = "Enter the next quantity" ' Set prompt.
Title = "Quantity" ' Set title.
Default = "" ' Set default.
' Display message, title, and default value.
Dim Msg, Style, Ttle, Help, Ctxt, Response, MyString
Msg = "Do you want to continue ?" ' Define message.
Style = vbYesNo + vbDefaultButton2 ' Define buttons.
Response = MsgBox(Msg, Style, Ttle, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
Set Mycmd = Me.Controls.Add("Forms.TextBox.1", name, True)
MyValue = InputBox(Message, Title, Default)
Mycmd = MyValue
Else ' User chose No.
MyString = "No" ' Perform some action.
End If
End Sub