Linking the module to the form? You should have this code in the form's
module, not in a separate module. If you want to put this code in a public
subroutine, you'll need to pass a variable object for the form to it so that
it can be used. For now, what I'm providing is an example of how the code
would be in the form's module.
OK - so what you want is to get the value of the field whose name is in the
label with the option group's value. A bit tricky, but this code should get
us started. What this code does is "crawl" through all the form's controls;
when it finds an option button, it tests the Option Value of that button
against the value of the option group to which it belongs; if they match and
the value is 2, the code reads the caption of the label that is attached to
the option button and then reads the value of the field from the form's
recordset and puts it into the value list string. When done, the value list
is assigned to the combo box.
Dim strValueList As String, strValue As String
Dim ctl As Control
strValueList = ""
For Each ctl In Me.Controls
If ctl.ControlType = acOptionButton Then
If ctl.OptionValue = ctl.Parent.Value And ctl.OptionValue = 2 Then
strValue = Me.Recordset.Fields(ctl.Controls(0).Caption).Value
strValueList = strValueList & strValue & ";"
End If
End If
Next ctl
If strValueList <> "" Then
strValueList = Left(strVL, Len(strVL) - 1)
Me.Combo229.RowSourceType = "Value List"
Me.Combo229.RowSource = strValueList
End If