none
Change contents of table with a Optionbutton RRS feed

  • Question

  • Dear Forum,

     

    As a student Im trying to change the contents of a table using optionbuttons.

    The idea is that the user selects a option(radio)button and then his selection (only one char) appears in a small table at the bottom of the page.

    Example:
    Is your hair Purple or Blond?

    option 1: Purple, Option 2: Blond      (with optionbuttons) 

    if option 1
    table cell 1 equals P
    if option 2
    table cell 1 equals  B

     

    I tried to do this in coding but I wasn't very succesful:

    Private Sub OptionButton1_Click()

    If OptionButton1_Click = True Then

    tablecell1 = "E"

    Else if optionButton2_Click = True Then

    tablecell1 = "T"

    End Sub

    I'm browsing the fora and internet for possible solutions but so far I've been unsuccessful.

    Your help would be greatly appriciated,

     

    kind regards,

     

    Chris. 

    • Moved by William Zhou CHN Wednesday, September 14, 2011 2:34 AM Coding for Developer (From:Word IT Pro Discussions)
    Monday, September 12, 2011 11:31 AM

Answers

  • Hi Chris,

    Below code is an example, please make some changes according to your scenario. Please have a try and let us know the situation on your side. 

    Private Sub OptionButton1_Click()
    ThisDocument.Tables(1).Cell(1, 1).Range.Text = "P"
    End Sub
    
    Private Sub OptionButton2_Click()
    ThisDocument.Tables(1).Cell(1, 1).Range.Text = "B"
    End Sub
    

    If you have any concerns, please feel free to follow up.

    Have a nice day.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Liliane Teng Monday, September 19, 2011 2:03 PM
    Friday, September 16, 2011 10:16 AM