Below is the code I am working with. I don't have it quite right yet.
I am trying to get the results of a select query to show as lables changing color on a form. This is what I got so far. I would like for the labels to change color when the values in the query match the caption (of the label) name. Thank you in advance!!!
Private Function IID_AfterUpdate()
Dim rstgtiaiq As New ADODB.Recordset
Dim ctrl As Control
' Open a recordset based on the WWReviewhelper query.
rstgtiaiq.Open "WWReviewhelper", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' If no allocatons previously set, display a message and exit.
If rstgtiaiq.RecordCount = 0 Then
DisplayMessage "There are NO allocations set on this part."
Exit Function
End If
For Each ctrl In Me.Controls
If TypeOf ctrl Is Label Then
Do Until rstgtiaiq.EOF
If ctrl.Caption = rstqtiaiq!GTWY Then
ctrl.ForeColor = vbBlue
rstgtiaiq.MoveNext
Loop
End Function
I am trying to get the results of a select query to show as lables changing color on a form. This is what I got so far. I would like for the labels to change color when the values in the query match the caption (of the label) name. Thank you in advance!!!
Private Function IID_AfterUpdate()
Dim rstgtiaiq As New ADODB.Recordset
Dim ctrl As Control
' Open a recordset based on the WWReviewhelper query.
rstgtiaiq.Open "WWReviewhelper", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' If no allocatons previously set, display a message and exit.
If rstgtiaiq.RecordCount = 0 Then
DisplayMessage "There are NO allocations set on this part."
Exit Function
End If
For Each ctrl In Me.Controls
If TypeOf ctrl Is Label Then
Do Until rstgtiaiq.EOF
If ctrl.Caption = rstqtiaiq!GTWY Then
ctrl.ForeColor = vbBlue
rstgtiaiq.MoveNext
Loop
End Function