P
Pierre
Morning and Happy New Year all.
I am having an issue with a code I'm trying to use to change the back color
of some text boxes I'm using on my form. The actual issue is not that the
code is not working. It’s just only working with one text box. I would like
to know how I would fix this code to change a group of numbers and not a
series of numbers.
i.e. "220, 222, 224, 226" - AND NOT - "220 To 226"
Now, when I try and enter it in example A it does not allow the comma.
Example B gives me an error because there are no odd numbers. I have tried
changing the numbers to odd numbers with no avail.
Any and All help in this matter is greatly appreciated.
Complete code below:
Private Sub Form_Current ()
Dim IngColor As Long
Dim IntVal As Integer
If InStr (Me.[Overall Classification], “SAMâ€) = 1 Then
IngColor = 255
ElseIf InStr(Me.[Overall Classification], “TSâ€) = 1 Then
IngColor = 65535
Else
IngColor = 0
End If
For IntVal = 220 To 226
Me.Controls(“Text†& IntVal).BackColor = IngColor
Me.Controls(“Text’ & IntVal).Value = Me.[Overall Classification]
Next
End Sub
I am having an issue with a code I'm trying to use to change the back color
of some text boxes I'm using on my form. The actual issue is not that the
code is not working. It’s just only working with one text box. I would like
to know how I would fix this code to change a group of numbers and not a
series of numbers.
i.e. "220, 222, 224, 226" - AND NOT - "220 To 226"
Now, when I try and enter it in example A it does not allow the comma.
Example B gives me an error because there are no odd numbers. I have tried
changing the numbers to odd numbers with no avail.
Any and All help in this matter is greatly appreciated.
Complete code below:
Private Sub Form_Current ()
Dim IngColor As Long
Dim IntVal As Integer
If InStr (Me.[Overall Classification], “SAMâ€) = 1 Then
IngColor = 255
ElseIf InStr(Me.[Overall Classification], “TSâ€) = 1 Then
IngColor = 65535
Else
IngColor = 0
End If
For IntVal = 220 To 226
Me.Controls(“Text†& IntVal).BackColor = IngColor
Me.Controls(“Text’ & IntVal).Value = Me.[Overall Classification]
Next
End Sub