Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default how to store user responses

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default how to store user responses

I created a user form with a textbox named txtQuantity_1 and a command
button named CommandButton1. I then put the following code in the UserForm
code module and it allowed me to enter quantities in the text box which were
then posted to the active sheet in column A. Give it a try and maybe you
can adapt it to your needs.

Private Sub CommandButton1_Click()
Dim lr As Long, sh As Worksheet
Set sh = ActiveSheet 'Change to actual sheet name
lr = sh.Cells(Rows.Count, "A").End(xlUp).Row
sh.Range("A" & lr + 1) = Me.txtQuantity_1.Text
cont = MsgBox("DO YOU NEED TO MAKE ANOTHER ENTRY?", vbYesNo, "CONTINUE?")
If cont = vbYes Then
Me.txtQuantity_1.Text = ""
Me.txtQuantity_1.SetFocus
End If
End Sub





"dan dungan" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default how to store user responses

Thanks,

It works as you say. Maybe I can adapt it.

Thanks again.

Dan
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
is it possible to store outlook user name in excel file Eddy Stan Excel Programming 1 October 15th 09 07:51 PM
User form - How to store data on press of enter key. NDBC Excel Programming 2 June 29th 09 12:02 PM
Limiting possible responses on multiple User Forms Cerberus Excel Programming 0 August 28th 08 09:06 PM
get some user info and store as constant Steve E Excel Programming 4 September 13th 06 07:28 PM
Using classes to store user credentials Philippe Pons Excel Programming 3 August 3rd 05 04:22 PM


All times are GMT +1. The time now is 10:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"