I'm creating a summary that uses Dcount() to count the number of records that meet certain criteria (# of projects in a state, for example). Once these values are calculated I'd like to change the ForeColor of the highest value to Red so that it sticks out. I can loop through the control elements on the form, but I'm trying to figure out how to change the fore color.
I have three textboxes:
tboxRegion2
tboxRegion3
tboxRegion4
This code loops through all of the textboxes on the form and finds the one with the highest value.
Code:
Dim c As Control Dim txt As TextBox
Dim high As Integer
Dim value As Integer
Dim tbox As String
high = 0
For Each c In Me.Controls
If TypeOf c Is TextBox Then
Debug.Print c
value = c
If value > high Then
high = value
tbox = c.Name
End If
End If
Next c
This code changes the ForeColor property to red:
Code:
Me.tboxRegion4.ForeColor = RGB(255, 0, 0)
What I need to do is combine the two code blocks by building the Me. statement using the variable tbox. For example:
Code:
"Me." & tbox & ".ForeColor = RGB(255,0,0)"
I need Access to evaluate this statement rather than treat it as a string.
Recommendations?