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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically put correct number of text boxes on a form

Status
Not open for further replies.

storl2

Programmer
Jun 3, 2004
47
US
I have a form that is a dynamic questionnaire. The number and content of the questions will change on a regular basis, so I am trying to make a form that will allow me to automatically pull the current questions and have the correct number of text boxes to display them on the form, along with the accompanying combo box for each question to allow the user to answer. I want to stay away from having bound text boxes with a form header/footer/detail section, if possible, but I know that would be the most obvious way to go about this.

I want to be able to let the person finish the questionnaire without it altering any data in the tables, and force them to click a command button that makes sure that they have answered all the questions and asks them if they are sure they want to save the answers. If they say yes, I want it to add new records in the table for their answers, or edit one if one already exists.

Any suggestions?
 
This would require a complete change in your data structure, so you may just reject it out of hand, but...one way to do this, and I think the most common one, is to have a table with a Question field and an Answer field. Then you can have as many questions as you'd like, though the user will have to do some figuring on how the UI will work...

If you do some googling you'll definitely find folks talking about how they've approached this problem in the past.

Jeremy

---
Jeremy Wallace
METRIX Project Coordinator
Fund for the City of New York
 
I think I might be able to do it if there is a way to create text boxes on a form dynamically using VBA. I have checked all my books, but can't find anything on that. Is there a way to create text boxes using code that anyone has seen?

I would basically count the number of questions in the table and create text boxes accordingly. Again, if anyone can give me a better solution, I would be extremely grateful.
 
Take a look at the Application.CreateControl method.
The form must be in design view I guess.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top