Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    8

    Unhappy Unanswered: Adding radio buttons to option group with VBA

    Hi everyone,

    I am hoping that someone can help me. I have looked everywhere and am at my whit's end.

    I am designing a dynamic survey form system. The user needs to be able to slect the questions for the survey from a list stored in a table.

    This entails creating the form for data entry on the fly with VBA. The form does not exist in the database until the VBA creates it on the fly. I have successfully created this form using drop down lists, but the preference is to use an option group with radio buttons for the answers to the questions (which are also different for each question and stored in a table). I have successfully created the form with the question, option group box and the answers with their associated radio buttons, but for the life of me I cannot figure out how to add or associate the radio buttons to the option group using VBA. I also unfortunately don't have the code with me to post so that you can see where I am at.

    I need to know how to create an option group and add items to it strictly in VBA code.

    Any help or suggestions would be greatly appreciated!

  2. #2
    Join Date
    Jan 2004
    Posts
    8
    Help!

  3. #3
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Smile

    SParki,
    I'm a bit lost in what your situation really is. How do you have that question field set up in your table? How did you create the OptionGroup? I would have a Question field setup in the table. Then pull that field over into the query the form is based on. Then with the ControlBox in FormDesign click the FieldList button to show all your fields. Click the OptionBox in the ControlBox and click and drag the Question field onto the form. Follow the wizard and SaveValueForLaterUse. See what that does for you. Hope that helps as it seems you really need help. Maybe someone else will kick in a suggestion or two for you.

    Bud

  4. #4
    Join Date
    Jan 2004
    Posts
    8
    Hi Bud,

    Thanks for replying.

    The question table has a primary key field with the question number and another field with the actual question. I have a second table with a field containing the answers and a field containing the question number which is linked to the question number from the first table.

    There is no form stored in the database application to make changes to. The form is created for each use at run time using VBA code. Therefore it is not possible to use the design environment to create the form. It is all done through code.

    The form is not based on a query. The form stores the answers selected on the form into another table that has the structure of a primary key field and then 2 or 3 fields storing customer information and then one field for each question in the complete set of questions. If a question is added to the list of available questions, the application adds a field to this table for the new question. It is designed this way for backwards compatibility.

    I have developed a routine that moves through the selected questions in the questions table. It reads the question into a variable and then creates a text box and writes the variable as the value of the text box. It then creates an acOptionGroup frame linked to the question number field for the ControlSource. I then run an sql routine to populate a record source with the answers for the question I am working on. With this I create one radio button and a text box with the answer as the value. These radio buttons are created within the option group frame. However, because they are created with code instead of in a design environment by draggin them into the option group frame, they do not associate with hte option group frame. They bahave as stand alone radio buttons.

    I have no idea and have been unable to find any way to create or modify the properties of these radio buttons using code so that they associate with the option group frame.


    ARGG! I would be pulling my hair out if I wasn't so folically challenged!

    Any help would be greatly appreciated.

    I have a working version of the code that creates a form on the fly that uses drop down lists for the answers, but the contractor wants radio buttons because it will speed up data entry.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •