[RESOLVED] Change BackColor
Thanks to much appreciated help from DKenny I now have a Word (2003) userfrom that loads values into comboboxes depending on a previous selection.
In some instances, this will result in some comboboxes having only one choice. In these instances I want to lock the combobox and change the backcolor. I have managed to lock, but can't change the backcolor - I receive an invalid qualifier message when testing.
Also, I'm sure I can shorten/improve the code because some of the items choices in cboChassisMake lead to the same results. For example, "DAF" "ERF" and "Foden" - Any ideas would be appreciated (I did try using OR but kept receiving errors). Here's the code.
VB Code:
With Me.cboGearboxMake
'First remove existing values from cboGearboxMake
.Clear
If Me.cboChassisMake.Value = "DAF" Then
'Add the appropriate items for DAF
.AddItem "Eaton"
.AddItem "ZF"
'Select standard gearbox
.ListIndex = 1
ElseIf Me.cboChassisMake.Value = "ERF" Then
'Add the appropriate items for DAF, ERF and Foden
.AddItem "Eaton"
.AddItem "ZF"
'Select standard gearbox
.ListIndex = 1
ElseIf Me.cboChassisMake.Value = "Foden" Then
'Add the appropriate items for Foden
.AddItem "Eaton"
.AddItem "ZF"
'Select standard gearbox
.ListIndex = 1
ElseIf Me.cboChassisMake.Value = "Iveco" Then
'Add the appropriate items for Iveco
.AddItem "ZF"
'Select standard gearbox
.ListIndex = 0
ElseIf Me.cboChassisMake.Value = "MAN" Then
'Add the appropriate items for MAN
.AddItem "ZF"
'Select standard gearbox
.ListIndex = 0
ElseIf Me.cboChassisMake.Value = "Mercedes" Then
'Add the appropriate items for Mercedes
.AddItem "Mercedes"
[VBCODE[COLOR=Red]].BackColor.RGB = RGB(123, 123, 123)[/[/COLOR]VBCODE]
.Locked = True
'Select the standard gearbox
.ListIndex = 0
ElseIf Me.cboChassisMake.Value = "Renault" Then
'Add the appropriate items for Renault
.AddItem "ZF"
'Select the standard gearbox
.ListIndex = 0
ElseIf Me.cboChassisMake.Value = "Scania" Then
'Add the appropriate items for Scania
.AddItem "Scania"
'Select the standard gearbox
.ListIndex = 0
ElseIf Me.cboChassisMake.Value = "Volvo" Then
'Add the appropriate items for Volvo
.AddItem "Volvo"
'Select the standard gearbox
.ListIndex = 0
Else
'Add all items
.AddItem "Eaton"
.AddItem "Mercedes"
.AddItem "Scania"
.AddItem "Volvo"
.AddItem "ZF"
End If
End With
End Sub