Access 2010 report question (1 Viewer)

gcarpenter

Registered User.
Local time
Today, 14:47
Joined
Oct 21, 2013
Messages
68
I have three option groups on a report. Each option group has a command button to apply the option group selection, and I have a command button that will apply the results if all three option groups are selected. Right now if a value in that option group is selected, the forecolor of the command button that corresponds to that option group will change colors, What I don't know is where to place my code for the command button that corresponds to all three option groups being selected, so that command button will change forecolor when all three option groups are selected.

Thanks for your help.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 19:47
Joined
Jul 9, 2003
Messages
16,285
Replace with your comand button name HERE:-
Me.Command46.Caption = "YES!!!"

Code:
Private Sub fAllOptionsSelected()
Dim strSubName As String
Dim strModuleName As String

strSubName = "fAllOptionsSelected"
strModuleName = "Form - " & Me.Name

On Error GoTo Error_Handler

Dim Ctrl As Control
Dim intNumbOff As Integer
Dim intCountSelected As Integer

      For Each Ctrl In Me.Controls
        If Ctrl.ControlType = acOptionGroup Then
            intNumbOff = intNumbOff + 1
                If Ctrl.Value >= 1 Then
                    intCountSelected = intCountSelected + 1
                End If
        End If
      Next
 
 If (intNumbOff - intCountSelected) = 0 Then
    Me.Command46.Caption = "YES!!!"
 End If

Exit_ErrorHandler:

    Exit Sub

Error_Handler:
        Select Case Err.Number
            Case 1 'When Required, Replace Place Holder (1) with an Error Number
                MsgBox "Error produced by Place Holder please check your code !  Error Number >>>  " _
                & Err.Number & "  Error Desc >>  " & Err.Description & " - Error From - " & strModuleName & ", " & strSubName
            Case Else
                MsgBox "Error From --- " & strModuleName & ", " & strSubName & " --- Error Number >>>  " & Err.Number _
                & "  <<< Error Description >>  " & Err.Description
        End Select
    Resume Exit_ErrorHandler
End Sub           'fAllOptionsSelected

'Call it like this
Private Sub Frame22_Click()
Call fAllOptionsSelected
End Sub
 

gcarpenter

Registered User.
Local time
Today, 14:47
Joined
Oct 21, 2013
Messages
68
Worked like a champ, thanks Uncle Gismo.....
 

Users who are viewing this thread

Top Bottom