Calling an option group from a subform using ADO

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmath
    New Member
    • Feb 2008
    • 2

    Calling an option group from a subform using ADO

    Hello!

    Here is the code I'm working with:
    Code:
    Private Sub opbAddNew_Click()
    
    Dim rstRiskRating As ADODB.Recordset
    Set rstRiskRating = New ADODB.Recordset
    
    With rstRiskRating
        .ActiveConnection = CurrentProject.Connection
        .CursorType = adOpenKeyset
        .LockType = adLockOptimistic
        .Open "Select * from tblRiskRating"
        .AddNew
            !PropertyID = Forms!frmNewRiskRating.txtPropertyID
            !ValidDate = Forms!frmNewRiskRating.txtValidDate
            [U]!Operational = Me!sfrmSponMgmt.optOperational[/U]
        .Update
    End With
    
    rstRiskRating.Close
    Set rstRiskRating = Nothing
    
    DoCmd.Close
    
    End Sub
    The line in bold is intended to populate the field [Operational] in a table. This is an option group (valued 1 through 5) called "optOperational " on subform "sfrmSponMg mt."

    My problem is simple, I can't seem to find the correct syntax to link the option group selection to the value to be added to the table. Is my syntax wrong? Or is there some trick to fetching a value from an option group that I'm unaware of?

    Any help would be greatly appreciated.

    Thanks,

    Michael
  • mmath
    New Member
    • Feb 2008
    • 2

    #2
    Never mind. I solved the problem by replacing the bolded line with this:

    !Operational = Form_frmNewRisk Rating.sfrmSpon Mgmt.Controls(o ptOperational)

    Thank you.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      Thanks for posting back with the solution.

      Comment

      Working...