Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
form inside a loop
I have a form that includes a number of inputs (we'll call it (name)
frmPO). The user inputs the information from a purchase order (i.e. company name, address, etc.) into frmPO. One of the text boxes (i.e. (name) txtPOItems) on frmPO includes an input for the number of items included in the purchase order. More than simply entering the number of items, I want the user to be able to enter the description of the item. I'm getting hung up on coding something that will allow the user to input the item description according to the number of items (whether 2 items or 15 items, etc.). Let me try to illustrate. I'll use the number 3 (i.e. frmPO.txtPOItems.Value is 3). Initially I thought that when the user submits the purchase order items (i.e. clicks a command button (name) cmdEnterItems) the event would trigger another form (i.e. frmItems.Show) that would allow the user to enter item 1 description into a text box (i.e txtItems). Upon submitting frmItems (i.e. clicks the command button (name) cmdSubmitItem) the frmItems would appear again, the user would enter item 2 description into the text box (txtItem), submit the form (cmdSubmitItem), frmItems would reappear, and the user would enter item 3 description (and so on for any number of items). After entering the 3 items, the user would finish filling out frmPO and then submit the form. Hopefully this makes sense. I have written the code below, but when frmAddItem.Show executes I don't know how to then create the event on frmAddItem such that it will remember what number in the loop it's on to retain the appropriate txtItem.Value (which I thought I could do with an array for outputting purposes in the spreadsheet). Private Sub cmdEnterItems_Click() Dim a For a = 1 To frmPO.txtPOItems.Value frmAddItem.Show Next End Sub What to do here? Private Sub cmdSubmitItem_Click() 'I'm not sure what to do here. Maybe somehow pass the txtItem back to the above procedure 'such that it is received inside the For Loop? End Sub Any help is greatly appreciated as I learn more about user forms and programming in general. Thanks in advance. Matt |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
form inside a loop
Something like this
Dim AryDesc Private Sub cmdEnterItems_Click() Dim a As Long With Me ReDim AryDesc(1 To .txtPOItems.Value) For a = 1 To .txtPOItems.Value frmAddItem.lblItems.Caption = "Description " & a frmAddItem.txtItems.Text = "" frmAddItem.Show AryDesc(a) = frmAddItem.txtItems.Text Next End With End Sub in frmPO, and Private Sub cmdSubmitItem_Click() Me.Hide End Sub in frmAddItems. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "matt" wrote in message oups.com... I have a form that includes a number of inputs (we'll call it (name) frmPO). The user inputs the information from a purchase order (i.e. company name, address, etc.) into frmPO. One of the text boxes (i.e. (name) txtPOItems) on frmPO includes an input for the number of items included in the purchase order. More than simply entering the number of items, I want the user to be able to enter the description of the item. I'm getting hung up on coding something that will allow the user to input the item description according to the number of items (whether 2 items or 15 items, etc.). Let me try to illustrate. I'll use the number 3 (i.e. frmPO.txtPOItems.Value is 3). Initially I thought that when the user submits the purchase order items (i.e. clicks a command button (name) cmdEnterItems) the event would trigger another form (i.e. frmItems.Show) that would allow the user to enter item 1 description into a text box (i.e txtItems). Upon submitting frmItems (i.e. clicks the command button (name) cmdSubmitItem) the frmItems would appear again, the user would enter item 2 description into the text box (txtItem), submit the form (cmdSubmitItem), frmItems would reappear, and the user would enter item 3 description (and so on for any number of items). After entering the 3 items, the user would finish filling out frmPO and then submit the form. Hopefully this makes sense. I have written the code below, but when frmAddItem.Show executes I don't know how to then create the event on frmAddItem such that it will remember what number in the loop it's on to retain the appropriate txtItem.Value (which I thought I could do with an array for outputting purposes in the spreadsheet). Private Sub cmdEnterItems_Click() Dim a For a = 1 To frmPO.txtPOItems.Value frmAddItem.Show Next End Sub What to do here? Private Sub cmdSubmitItem_Click() 'I'm not sure what to do here. Maybe somehow pass the txtItem back to the above procedure 'such that it is received inside the For Loop? End Sub Any help is greatly appreciated as I learn more about user forms and programming in general. Thanks in advance. Matt |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
form inside a loop
On Feb 26, 2:28 am, "Bob Phillips" wrote:
Something like this Dim AryDesc Private Sub cmdEnterItems_Click() Dim a As Long With Me ReDim AryDesc(1 To .txtPOItems.Value) For a = 1 To .txtPOItems.Value frmAddItem.lblItems.Caption = "Description " & a frmAddItem.txtItems.Text = "" frmAddItem.Show AryDesc(a) = frmAddItem.txtItems.Text Next End With End Sub in frmPO, and Private Sub cmdSubmitItem_Click() Me.Hide End Sub in frmAddItems. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "matt" wrote in message oups.com... I have a form that includes a number of inputs (we'll call it (name) frmPO). The user inputs the information from a purchase order (i.e. company name, address, etc.) into frmPO. One of the text boxes (i.e. (name) txtPOItems) on frmPO includes an input for the number of items included in the purchase order. More than simply entering the number of items, I want the user to be able to enter the description of the item. I'm getting hung up on coding something that will allow the user to input the item description according to the number of items (whether 2 items or 15 items, etc.). Let me try to illustrate. I'll use the number 3 (i.e. frmPO.txtPOItems.Value is 3). Initially I thought that when the user submits the purchase order items (i.e. clicks a command button (name) cmdEnterItems) the event would trigger another form (i.e. frmItems.Show) that would allow the user to enter item 1 description into a text box (i.e txtItems). Upon submitting frmItems (i.e. clicks the command button (name) cmdSubmitItem) the frmItems would appear again, the user would enter item 2 description into the text box (txtItem), submit the form (cmdSubmitItem), frmItems would reappear, and the user would enter item 3 description (and so on for any number of items). After entering the 3 items, the user would finish filling out frmPO and then submit the form. Hopefully this makes sense. I have written the code below, but when frmAddItem.Show executes I don't know how to then create the event on frmAddItem such that it will remember what number in the loop it's on to retain the appropriate txtItem.Value (which I thought I could do with an array for outputting purposes in the spreadsheet). Private Sub cmdEnterItems_Click() Dim a For a = 1 To frmPO.txtPOItems.Value frmAddItem.Show Next End Sub What to do here? Private Sub cmdSubmitItem_Click() 'I'm not sure what to do here. Maybe somehow pass the txtItem back to the above procedure 'such that it is received inside the For Loop? End Sub Any help is greatly appreciated as I learn more about user forms and programming in general. Thanks in advance. Matt- Hide quoted text - - Show quoted text - Bob, Thank you very much; I appreciate it. The code works very well. Matt |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
use time functions inside if loop | Excel Worksheet Functions | |||
Increment stopvalue inside a For loop | Excel Programming | |||
Loop inside a Loop | Excel Programming | |||
Create an array inside a For...Next loop | Excel Programming | |||
Placing a form inside of a form | Excel Programming |