Here's my button code, and I want to see if I can do something different so I don't have to repeat the same code for each of my 14 buttons in my option group:
The buttons in the option group "grpSections" are named grpS1 - grpS14 and represent sections on my questionnaire. The query above uses the value of the option group as criteria with [Forms]![frmMain].[Controls]![grpSections].[value] to calculate the DCount on RspnsID for each section.
So it all boils down to this. Is there a way to put code in the option group's on click or after update event to grab the value of the button that has just lost focus, to run the query above and change THAT button fore color? So for example as a user goes from section 1 to 2 by clicking the grpS2 button the query would check for complete questions in section 1 and if there are questions missed then change the fore color for grpS1.
As always, thanks everyone for your help!
Code:
Private Sub grpS1_LostFocus()
Dim intCount As Integer
Dim lngRed As Long, lngBlack As Long
lngRed = RGB(186, 20, 25)
lngBlack = RGB(64, 64, 64)
intCount = DCount("[RspnsID]", "qxtbChkSectionsComplete")
If intCount > 0 Then
' missing questions, change button ForeColor to red
Me!grpS1.ForeColor = lngRed
Me!grpS1.PressedForeColor = lngRed
Me!grpS1.HoverForeColor = lngRed
Else
' questions complete, change button ForeColor to black
Me!grpS1.ForeColor = lngBlack
Me!grpS1.PressedForeColor = lngBlack
Me!grpS1.HoverForeColor = lngBlack
End If
End Sub
So it all boils down to this. Is there a way to put code in the option group's on click or after update event to grab the value of the button that has just lost focus, to run the query above and change THAT button fore color? So for example as a user goes from section 1 to 2 by clicking the grpS2 button the query would check for complete questions in section 1 and if there are questions missed then change the fore color for grpS1.
As always, thanks everyone for your help!