Form 1 reference to radio buttons from Form 2 RRS feed

  • Question

  • I have a button on Form1. When clicking on this button, Form 2 will be opened with a list of radio buttons for user selection. The user can select more than one radio button. After the user made selection on radio buttons, s/he clicks on the Submit button on Form 2. Then Form 2 is closed and Form 1 is visible. Those radio buttons with its label contents will be pulled out from Form 2 and put in a text field on Form 1.

    Do you know how to do this? Can you please help? Thank you.  

    Thursday, July 20, 2017 9:54 PM

All replies

  • Hi,

    If Form1 stays open while Form2 is open, then you can use a form reference to transfer data between them.

    Hope it helps...

    Thursday, July 20, 2017 10:15 PM
  • Instead of closing Form2 hide it by setting its Visible property to False.  If Form2 has been opened in dialogue mode this will cause code execution to resume in Form1.  You can then reference Form2's controls in the usual way.  Close Form2 with code in Form1's module once you have finished with it.

    Ken Sheridan, Stafford, England

    • Edited by Ken Sheridan Thursday, July 20, 2017 11:17 PM Typo corrected.
    Thursday, July 20, 2017 11:16 PM
  • Hi ttim,

    As far as I know, radio button in access means Option Group, right?

    I think the key point is how to get selected options' label contents. A select option in Option Group contains an Option Button control and a label control, they are put together but don't have association so you could not get the selected option's label via the selected option directly.

    As a workaround, you could put the label content into tag property of the correspondent option button. Or you could refer to Tom's solution in this thread

    You could iterate through controls in Form2 and look for Option Group to get selected option.

    You could close Form2 after you send label contents to text in Form1.

    Here is the example.

    Button Click in Form1

    Private Sub btnOpenForm2_Click()
    DoCmd.OpenForm "Form2"
    End Sub

    Button Click in Form2

    Private Sub SendToForm1_Click()
    Dim ogroup As OptionGroup
    Dim str As String
    For Each con In Me.Controls
    If TypeName(con) = "OptionGroup" Then
    Set ogroup = con
    str = str + ogroup.Controls(ogroup.Value * 2).Caption & ","
    End If
    Next con
    Debug.Print str
    Forms!Form1!txtInForm1.Value = str
    DoCmd.Close acForm, Me.Name
    End Sub

    Best Regards,


    Friday, July 21, 2017 7:42 AM
  • Hi ttim,

    Has your original issue been resolved? If it has, I would suggest you mark the helpful reply or provide your solution and then mark it as answer to close this thread. 
    If not, please feel free to let us know your current issue.

    Best Regards,


    Thursday, August 3, 2017 8:43 AM