Userform data to create form fields

I

ivory_kitten

Hi, I want to create a template that asks multiple questions and then based
on the user's answers, inserts relevant text and form fields. For example:

Question: Do you require packing service?
If the answer is Yes, then insert
(Heading format) Packing Charges:
(Form Field - Drop down) (Form Field - Text Currency)
If the answer is No, insert nothing

Question: Do you require additional services?
If the user answers Yes then insert
(Heading Format) Additional Service Charges:
If the answer is No, insert nothing

Question: Do you require car transport?
If user answers Yes then insert (under additional services heading from above)
(Form field - Dropdown) (Form field - Text Currency)
If No, insert nothing

Etc. there are a lot more options but I can create them later - if I can
even achieve this!
 
D

Doug Robbins - Word MVP

Put the questions in a userform. probably as the captions to checkboxes and
then have a command button that iterates through the checkboxes on the
userform, inserting the appropriate files into the document based on the
status of the checkbox.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
I

ivory_kitten

I have got as far as the frames with the radio buttons for Yes or No, and
have the a Submit command button, am unsure how to write the code to evaluate
the responses.

Would it be better to do this using a table and show/hide rows based on the
userform responses?

You have been most helpful on all my queries!
 
D

Doug Robbins - Word MVP

I would think that it would be a lot simpler to use a checkbox for each item
rather than radio buttons. You should give each checkbox a name that bears
some relationship to its purpose. Then you have to iterate through the
checkboxes and determine their value and take the appropriate action. In
the template, you could have each piece of data that may or may not be
deleted inside a bookmark, once again with a meaningful name and you just
delete the .Range of the bookmarks that are related to the unchecked
checkboxes.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
I

ivory_kitten

Ok, I have three checkboxes called Packing, Storage, Additional Services.
How do I use them to insert the data in to my document?

Like if Packing = true then insert "Text & form fields"

Can you use VBA to insert form fields?
 
I

ivory_kitten

Ok, I got it working using the show/hide rows! I've kept it simple to start
with and have only 2 options on my UserForm (frmOptions): () = checkbox

Packing Option 1
() Required

Packing Option 2
() Required

My Code is:
Private Sub Submit_Click()
If Pack1 = True Then
With ActiveDocument
.Tables(1).Rows(5).Range.Font.Hidden = False
.Tables(1).Rows(6).Range.Font.Hidden = False
End With
Else
With ActiveDocument
.Tables(1).Rows(5).Range.Font.Hidden = True
.Tables(1).Rows(6).Range.Font.Hidden = True
End With
End If
If Pack2 = True Then
With ActiveDocument
.Tables(1).Rows(7).Range.Font.Hidden = False
End With
Else
With ActiveDocument
.Tables(1).Rows(7).Range.Font.Hidden = True
End With
End If
Unload Me
End Sub

YAY!!!!
 

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