Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2011

    Unanswered: VBA problems with Database

    I am trying to input data by using radio buttons in a form which I have made in the access GUI. The form is basic and has three radio buttons one for red, green and yellow. I want the form to record the users selection and record the information in the table at the back.

    The form is bound and the control is also bound. The table name is 'table2'
    Any ideas on how I can get this to link up?

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    If the form is bound, the easiest way consists in creating an option group on the form and place the three radio buttons in the group. You then assign the values you want to store into the table to the OptionValue property of each radio button. Finally, you set the ControlSource property of the option group to the name of the column in the table.

    Unfortunately, OptionValue can only be numeric. If you want to store another data type (e.g. text values such as "Red", "Green", "Yellow") it becomes a little more complex. Here is a possibility:

    1. Add a Text Box control to the form (name: Text_Colour), set its ControlSource property to the name of the column in the table that will store the text colour data ("Red", "Green, "Yellow") and, optionally set its Visible property to No.

    2. Add an Option Group control to the form (name: Frame_Colour) and add three radio buttons to it with their OptionValue property set to 1 (Red), 2 (Green) and 3 (Yellow), respectively.

    3. Create the following VBA procedure in the form module and link it to the AfterUpdate property of the option group:
    Private Sub Frame_Colour_AfterUpdate()
        Select Case Me.Frame_Colour.Value
            Case 1  ' Red
                Me.Text_Colour.Value = "Red"
            Case 2  ' Green
                Me.Text_Colour.Value = "Green"
            Case 3  ' Yellow
                Me.Text_Colour.Value = "Yellow"
        End Select
    End Sub
    Have a nice day!

Posting Permissions

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