Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically adding text boxes to a Word form

Status
Not open for further replies.

vmaruv

Programmer
Apr 8, 2002
102
US
Hi,

I have a requirement in my word form where the user has a choice to add or delete text boxes to the word form dynamically. There are some values that the user will enter in the form that depends on each user and cannot be static. In case he has added more text boxes than required, he should have the option to delete.

I am unable to figure out how this can be done. Any help is greatly appreciated. I'm new to this and am struggling!

Thanks in Advance.

V
 




When you refer to a Word Form, do you mean...

1. a PROTECTED document with Word Form Fields

2. an PROTECTED document with control toolbox "fields"

3. a VBA UserForm that interfaces the user and the document.

4. Something else?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I mean a protected document with control toolbox fields, with VBA code.

Thanks in Advance for your help.
 




Controls' visible property can be either True or False.

Please explain in more detail, what you are tyring to accomplish functionally.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Sorry if I am not able to explain it correctly. I am new to this and am struggling with this.
To be more clear, I have created a word template and added controls like textbox, combobox, buttons etc using the control toolbox fields.

I am writing VB code behind each field to achieve what I want the form to do, the form basically submits data to an access database on the click of the Submit button and retrieves data on the click of retrieve button.

In this process, the user will want to add data dynamically with text boxes, as mentioned in my first post, which I need help with. Hope this helps you in providing me with a solution. Thanks again!
 



So you don't really need a WORD document to do this, do you? You functionally defined an Inquiry, Add, Change, Delete database user interface.

So how many different form formats are you anticipating?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
To be more elaborate, the form basically captures "Test Summary Report" data and the user has certain Test criteria that he indicates whether it was met or not met. These criteria are dynamic and will vary from each user (tester in this case) and each project. This information has to be captured in text boxes dynamically during run time (maybe we can have an option of asking the user how many text boxes he wants to add ? just an idea in my mind) and add those many text boxes to the form.
so, if the user wants to add 4 text boxes to input data, the form should have 4 boxes.

I have worked on infopath form earlier where there is an option to add repeating table (and want to achieve the same functionality), if this info helps.

Thanks a lot.
 
We have been having issues with portability and the option given to me was to use Word forms to be able to achieve this. Hence I started to work and almost completed the form, except for this part.
i have the same form, with just two buttons, one to submit data, and another to Retrieve and update the data.
 



"so, if the user wants to add 4 text boxes to input data, the form should have 4 boxes."

4 boxes for WHAT? What if he want 40 or 400 boxes? Is there an upper bound?

Could you show some specific examples?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
The text boxes will store the test criteria details and the Met Criteria. There will not be criteria as many as 400 but we could limit it to about 15 to 20 max (I'm guessing). We can set the upper bound to some number as 20 - if required. But I'm pretty sure it does not go so far. I have seen metrics upto 6 to 8 criteria so far(where the users input using infopath form). There is an option to add repeating table(with text boxes etc) in infopath. But the problem is that infopath requires it to be installed on all the client computers and the software itself is licensed and all the users are not able to use the forms because of that. Hence this substitute of word forms.
 
Any ideas skip? I'm looking forward for your help!Please...
 



Add ALL your controls to the form.

Use code to control when they are visible and where they appear on the form.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thats one good idea. Thanks! But please also try to think if there are any other alternatives. I really appreciate your help. TekTips has always been my best friend when I needed coding help! Thanks a ton again.
 




You could ADD and DELETE on the fly also, but I prefer the former.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip: "Controls' visible property can be either True or False."

We have been through this. This is not correct for controls added with the Controls toolbar.

vmaruv: "I have created a word template and added controls like textbox, combobox, buttons etc using the control toolbox fields. "

Admitedly, vmaruv uses control "toolbox"...not toolbar.

If they are indeed using the toolbox, then these are controls on a userform, and yes they DO have a Visible property. However, if they are using the Control toolbar for controls IN the document - and they may be...it is hard to know for sure - then they do NOT have a Visible property.

Adding ActiveX controls dynamically is (IMO) not a great idea. I suppose there can be a case for it, but I have never really seen a valid one. If there is a need for a variable number of textboxes - and THAT I can see as being quite valid - then that determination should be upfront, and the document adjusted accordingly. In other words, find out how many you need, and then build the document to fit the requirement.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top