Link to home
Start Free TrialLog in
Avatar of vdhavala
vdhavala

asked on

Dynamically Adding controls to word VBA form

Hi Experts!

I am extremely new to Word VBA and not even sure of all the functions and functionality that it can provide. I am able to complete the part that involves static fields and looking for help with dynamic fields. Below is the requirement I'm stuck with.

1. I have a word form with control toolbox fields in it. I have a requirement where I need to insert controls dynamically in the form when it is opened. I need to add text box and cotrol box one at a time when a add button is clicked and remove one at a time when a delete button is clicked. This is because, there are some values that the user will enter in the form that depends on each user and cannot be static and predefined in the form. And this needs to be added in a specific area o the form (not to the end - has to be added somewhere in the middle or a specific place in the form). - this is to replicate the add row feature of repeating tables in infopath (if this info helps!)

2.once the controls are added and filled with info, Submit to Database is clicked and the information entered in the form needs to be submitted to my database (access for now).  These dynamic fields are submitted to a special (different ) database and the report id is the number with which we can identify the rows.

3. When I click Retrieve button, the info from the database based on that report id needs to be retrieved for these fields from the db and I need to populate the info back to the form in these dynamic fields on the form.

This is my first post here and i have heard a lot about your expert help! Thanks in Advance.
Avatar of puppydogbuddy
puppydogbuddy

see this link for an excellent tutorial on the subject:
                       http://pubs.logicalexpressions.com/pub0009/LPMArticle.asp?ID=259
Why not have the controls on the form all of the time, but hidden?  You can then unhide them when required
Avatar of vdhavala

ASKER

Thanks. But with this, I am able to add controls to a form on the document. I am not able to add them directly on the document. It doesn't give me the option. Any ideas ?
ASKER CERTIFIED SOLUTION
Avatar of vdhavala
vdhavala

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial