T
Tom
I have a crosstab query from which I want to pull 2 fields into a form.
In the crosstab query, these 2 fields contain numeric data. Their fields
name are "1" and "2" (for testing purposes right now).
In the form, I want to use VBA code to show a "color" (red, yellow, green)
of the textbox. The color is driven by the numeric value (pulled from the
Crosstab qry).
I use the following VBA code which throws me an error 2458.
*********************
Private Sub Form_Current()
Dim i1 As Integer
For i1 = 1 To 2
SetColors Me(i1)
Next i1
End Sub
*********************
Private Sub SetColors(c As Control)
Select Case c
Case Is = 0: c.BackColor = 16777215 'white
c.ForeColor = 16777215
Case Is <= 25: c.BackColor = 255 'red
c.ForeColor = 255
Case Is <= 50: c.BackColor = 33023 'orange
c.ForeColor = 33023
Case Is <= 75: c.BackColor = 65535 'yellow
c.ForeColor = 65535
Case Is <= 100: c.BackColor = 32768 'green
c.ForeColor = 32768
Case Else: c.BackColor = 8421504 'gray
c.ForeColor = 8421504
End Select
End Sub
*********************
This code works fine in another application (which does not use crosstab
queries though).
Right now, when I open the form, I get the following error:
"Run-time error '2458': The control number you specified is greater than
the number of controls".
Since I only have 2 controls (1 & 2) and i1= "1 to 2", I don't know what the
problem is.
Does anyone know how I can fix it?
Thanks,
Tom
In the crosstab query, these 2 fields contain numeric data. Their fields
name are "1" and "2" (for testing purposes right now).
In the form, I want to use VBA code to show a "color" (red, yellow, green)
of the textbox. The color is driven by the numeric value (pulled from the
Crosstab qry).
I use the following VBA code which throws me an error 2458.
*********************
Private Sub Form_Current()
Dim i1 As Integer
For i1 = 1 To 2
SetColors Me(i1)
Next i1
End Sub
*********************
Private Sub SetColors(c As Control)
Select Case c
Case Is = 0: c.BackColor = 16777215 'white
c.ForeColor = 16777215
Case Is <= 25: c.BackColor = 255 'red
c.ForeColor = 255
Case Is <= 50: c.BackColor = 33023 'orange
c.ForeColor = 33023
Case Is <= 75: c.BackColor = 65535 'yellow
c.ForeColor = 65535
Case Is <= 100: c.BackColor = 32768 'green
c.ForeColor = 32768
Case Else: c.BackColor = 8421504 'gray
c.ForeColor = 8421504
End Select
End Sub
*********************
This code works fine in another application (which does not use crosstab
queries though).
Right now, when I open the form, I get the following error:
"Run-time error '2458': The control number you specified is greater than
the number of controls".
Since I only have 2 controls (1 & 2) and i1= "1 to 2", I don't know what the
problem is.
Does anyone know how I can fix it?
Thanks,
Tom