Run form a number of times depending on first form

M

Marissa

I'm a little lost and need some help.

I have a group of forms that I intend to use to populate a form which will
eventually be emailed out. The first form asks the user for a number of
units. Then I need the user to fill out another form for each of those units.
So far I have:

Sub CommandButton1_Click()
Dim CompNum
'CompNum is the name of the text box where the user enters the number of units
For n = 0 To CompNum
compressordata1.Show
' show the next form
Next n
comp1.Hide
' hide the first form
End Sub

Then I have my other form which has a series of text boxes and combo boxes.
At the end there are three command boxes: back, next, and cancel. I don't
know what code to put in the next box to make it complete the cycle and then
close when the right number of forms has been filled in.

Thanks for your help.
 
D

David Sisson

Are the forms, userforms that you've built in the VBA editor? if
so...

Sub Build_click()

NumOfUnits = Val(textbox1)
For N = 1 to NumOfUnits

'Positive numbers have a space for the + sign, so trim it off
N2 = trim(n)
compressordata & N2.show

Next N

end sub


Then I have my other form which has a series of text boxes and combo boxes.
At the end

End of what? All the forms, or the first form for the units?
there are three command boxes: back, next, and cancel. I don't

I'm not real sure what you mean here, could you provide a little more
detail.

David
 
M

Marissa

David,

Thanks for the reply. Yes, my user forms are in the VBA editor. I will try
your suggestion later.

Regarding the second part,
After the user enters the number of units, they are taken to the next form
where they enter the detail information for each unit. After they fill out
all the fields, I have entered 3 command buttons, one to go back, one to
cancel, and another to continue or "next". I'm not sure what code I should
use for the "next" button so that the form repeats the right number of times
and THEN goes to the next step.

Should I be using your code here, or in my original form (where they enter
the number of units)?

Thanks!
 
M

Marissa

I'm getting a compile error with your code: "Invalid use of property"
(by the way, I took out the space between "compressordata" and "&" since it
was giving me another error with the space)
 
D

David Sisson

Sorry about that. I just pulled that off the top of my head. I'm
suffering from a head cold and my wife claims I don't think coherent
when I'm sick. :p

After rereading your request, I have a different suggestion. Would it
be more pratical to add a MultiPage dialog box? If you look on the
toolbox>control dialog in the editor, the icon is on the bottom, second
from the left.

If you can predict the maximum number of 'forms'(tabs or pages) that a
user would use, you could simply add the maximum number of pages. Then
make your first tab/page to display, "How many Units?". Then you
simply enable the pages you need. The user can then move around as
much as needed to key in the information. After inputing all the info,
they return to the first page where you'll have a Create Master Form
click button.

Because what your asking to do is possible, but this is MUCH, MUCH
simpler.

What are you doing with the information collected? Are you storing it,
or printing it?

If you're printing it, you could even have a template that is your
form. After asking for the number of units, loop through and actually
insert the template X number of times. Then the user has a standard
document they fill in.

David
 
M

Marissa

David,

That's OK. Apparently your sick head is still better than my clear head.

I like your second suggestion. Is there a limit to the number of tabs or
pages on one form? I think our maximum would be 8 units.

What I want to do is have the user enter everything on these forms and this
information is automatically entered into a template, which they can then
print or save if they want, but definitely emailed back to us.

Thanks,

Marissa
 
D

David Sisson

I like your second suggestion. Is there a limit to the number of tabs
or
pages on one form? I think our maximum would be 8 units.

Max is 255, I think. (Whoa, there I go again.)
What I want to do is have the user enter everything on these forms and this
information is automatically entered into a template, which they can then
print or save if they want, but definitely emailed back to us.

That's all possible.

Send me a sample form and I'll put something together for you to get
you started.

Send it to dsisson At hotmail dot com.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top