Option Groups

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BarbaraB
    New Member
    • Oct 2008
    • 2

    Option Groups

    Is there anyway of returning the value of an option group (in access 2003) back to what it was before any entry was made? I frequenty find people are wishing to remove there answer but with an option group it seems as if once you have made a choice, although you can change the choice, there is no way of returning it to its original state of having nothing selected. I know I can do this with a combo box by simply deleting the entry but I was hoping it could also be done with an option group. Any help appreciated
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi BarbaraB, and Welcome to Bytes!

    Depending on what you want to do there are several ways to revert the option group back. One is to reset the value of the option group to the DefaultValue property of the frame concerned. You can test this by placing the following line in the On Click code of a suitable button:

    Code:
    me![name of your option group] = me![name of your option group].DefaultValue
    You can also clear the option group completely (no default choice displayed) by setting it to null:

    Code:
    me![name of your option group] = Null
    -Stewart

    Comment

    • BarbaraB
      New Member
      • Oct 2008
      • 2

      #3
      Thanks, worked a treat. A nice simple solution.

      Comment

      • byronh
        New Member
        • Jan 2009
        • 1

        #4
        Option Group Help - Open & Overdue

        Hi, first time posting here and hope this question hasn't already been answered elsewhere. Got frame and option group help from Martin Green's Access Tips to create an action tracking option group to filter records for a report.

        The options for the "Apply Filter" button for filtering on the Action Status are: Open, Closed, Late, Overdue and All.

        Everything works fine for the filter except that for viewing Open actions, I would like to see both Open and Overdue actions as no action can be Overdue (for closure) without also being Open.

        I have amended the Martin Green code accordingly and here it is below:

        Private Sub cmdApplyFilter_ Click()
        Dim strSource As String
        Dim strOwner As String
        Dim strContract As String
        Dim strDivision As String
        Dim strStatus As String
        Dim strFilter As String
        ' Check that the report is open
        If SysCmd(acSysCmd GetObjectState, acReport, "rptMainDat a") <> acObjStateOpen Then
        MsgBox "You must open the report first."
        Exit Sub
        End If
        ' Build criteria string for Source field
        If IsNull(cboSourc e.Value) Then
        strSource = "Like '*'"
        Else
        strSource = "='" & cboSource.Value & "'"
        End If
        ' Build criteria string for Owner field
        If IsNull(cboOwner .Value) Then
        strOwner = "Like '*'"
        Else
        strOwner = "='" & cboOwner.Value & "'"
        End If
        ' Build criteria string for Contract field
        If IsNull(cboContr act.Value) Then
        strContract = "Like '*'"
        Else
        strContract = "='" & cboContract.Val ue & "'"
        End If
        ' Build criteria string for Division field
        If IsNull(cboDivis ion.Value) Then
        strDivision = "Like '*'"
        Else
        strDivision = "='" & cboDivision.Val ue & "'"
        End If
        ' Build criteria string for Status field
        Select Case fraStatus.Value
        Case 1
        strStatus = "='Open'"
        Case 2
        strStatus = "='Closed'"
        Case 3
        strStatus = "='Late'"
        Case 4
        strStatus = "='Overdue' "
        Case 5
        strStatus = "Like '*'"
        End Select
        ' Combine criteria strings into a WHERE clause for the filter
        strFilter = "[Contract] " & strContract & " AND [Source] " & strSource & " AND [Owner] " & strOwner _
        & " AND [Division] " & strDivision & " AND [Status] " & strStatus
        ' Apply the filter and switch it on
        With Reports![rptMainData]
        .Filter = strFilter
        .FilterOn = True
        .txtReportSubti tle.Value = _
        "Division: " & cboDivision.Val ue
        End With


        All assistance much appreciated,
        Byron

        Comment

        Working...