JWColby
jwcolby at colbyconsulting.com
Thu Aug 31 11:39:21 CDT 2006
Definitely a class. Pass in pointers to the controls to the class as the form opens. Store the control pointers in variables in the class, dimensioned Withevents. Withevents (after update) for the answer controls to "hear" the user's clicking on the controls. Discover the maximum number of answers ever encountered (yea, yea, but dynamically creating controls in Access is ...). Create the maximum number in advance. Hide/unhide the controls. Discover the label associated with a control (described here in the past, ask if you need and I'll find my code) Load the questions from the table and stuff them into the labels. Use the events from the answer controls to manipulate the integer control. Cool stuff, "easy" with classes and withevents. You could do it all directly in the form of course, and may want to initially to get it up and running, but if the app is very complex you may find another form which needs the same functionality and then having it in a class "just works". John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of artful at rogers.com Sent: Thursday, August 31, 2006 11:43 AM To: Access Developers discussion and problem solving Subject: [AccessD] Data-driven option buttons I think that I have asked this question before, but I can't find anything in my emails that pertains, so... Assume that a table T1 has several columns C1...C5, containing text, and another column containing an integer. (Let's sidestep the normalization issue, I am aware of that and trying to keep the example simple.) Here is the scenario: There is a Question column in T1, containing the text of a question to ask the user. The columns C1..C5 contain text representing possible answers to the question, from which the user can select exactly one answer. The integer column stores the number of the answer selected. For example: Q: On a scale of 1 to 5, do you consider yourself: a) a Genius b) quite smart but not a genius c) about average d) slower than most people I know e) smarter than a cucumber but it's close I would like the interface to present the question and then list its possible answers in the form of a set of option buttons, whose After-Update event will record the number of the option selected. This means that I must a) determine the number of possible answers; b) create that many option buttons (or alternatively create a maximum number and hide the irrelevant ones); and c) populate the labels for the buttons with the text stored in columns C1...C5. I can't figure out a cool way to do this. Any ideas, friends? TIA, Arthur -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com