我正在使用下面的代码来更改组合框和标签的属性。我还有另外 40 个组合框和标签(组合 2、组合 3、组合 4 ......)。有没有办法我可以重用代码而不是复制代码并且必须手动更改每个组合框和标签的名称。
If (Combo1 = 1) Then
DoCmd.SetProperty "Combo1", acPropertyBackColor, "255"
DoCmd.SetProperty "Label1", acPropertyCaption, "POOR"
ElseIf (Combo1 = 2) Then
DoCmd.SetProperty "Combo1", acPropertyBackColor, "2895086"
DoCmd.SetProperty "Label1", acPropertyCaption, "FAIR"
ElseIf (Combo1 = 3) Then
DoCmd.SetProperty "Combo1", acPropertyBackColor, "35584"
DoCmd.SetProperty "Label1", acPropertyCaption, "GOOD"
ElseIf (Combo1 = 4) Then
DoCmd.SetProperty "Combo1", acPropertyBackColor, "52480"
DoCmd.SetProperty "Label1", acPropertyCaption, "VERY GOOD"
ElseIf (Combo1 = 5) Then
DoCmd.SetProperty "Combo1", acPropertyBackColor, "64636"
DoCmd.SetProperty "Label1", acPropertyCaption, "EXCELLENT"
Else
DoCmd.SetProperty "Combo1", acPropertyBackColor, "16579836"
DoCmd.SetProperty "Label1", acPropertyCaption, ","
End If