I have a form with a few controls, one of them is a command button. Since I want those controls to reflect the number of records in the table in my DB, I started them with Index = 0 and I load as many controls as I need in the code, something like:
[pre]
For I = 1 To rst.RecordCount
Load cmdSQL(I)
With cmdSQL(I)
.Left = cmdSQL(1).Left
.Top = cmdSQL(I - 1).Top + cmdSQL(1).Height + 50
.Visible = True
End With
Next I
[/pre]
That works great.
Now, I need to ‘mark’ some command buttons, so – I figured – I will just change their BackColor property. I did set cmdSQL(0) Style property to 1 – Graphical and I can change its BaclColor just fine, and if I run the code and load all other controls, all command buttons have the new color. Great!
But I don’t want ALL command buttons to change color, I just want certain buttons to do that. So, in the code I have:
[tt]cmdSQL(10).BackColor = vbYellow[/tt][blue]
The color does NOT change. Why not?[/blue]
I can check the Style of this button:
[tt]? cmdSQL(10).Style[/tt]
And I get 0, which is NOT what I set the initial button to.
0 is Standard, 1 is Graphical.
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson
[pre]
For I = 1 To rst.RecordCount
Load cmdSQL(I)
With cmdSQL(I)
.Left = cmdSQL(1).Left
.Top = cmdSQL(I - 1).Top + cmdSQL(1).Height + 50
.Visible = True
End With
Next I
[/pre]
That works great.
Now, I need to ‘mark’ some command buttons, so – I figured – I will just change their BackColor property. I did set cmdSQL(0) Style property to 1 – Graphical and I can change its BaclColor just fine, and if I run the code and load all other controls, all command buttons have the new color. Great!
But I don’t want ALL command buttons to change color, I just want certain buttons to do that. So, in the code I have:
[tt]cmdSQL(10).BackColor = vbYellow[/tt][blue]
The color does NOT change. Why not?[/blue]
I can check the Style of this button:
[tt]? cmdSQL(10).Style[/tt]
And I get 0, which is NOT what I set the initial button to.
0 is Standard, 1 is Graphical.
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson