Link to home
Start Free TrialLog in
Avatar of shirt10
shirt10

asked on

How To Set A Forms Background Color To Be One of X Colors?


Hey all,

I have a small access database which my department enters review information into all day.
Last week for April Fools I added the code below to randomly set the background color below for some (and for three of the guys to always set it to hot pink).

Private Sub Associate_LostFocus()
   
    Select Case Associate
        Case "Mary Anderson", "Kelly Wright"
            Me.Section(acDetail).BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
        Case "Nick Dormer", "Shawn Justice", "Earl Onstott"
            Me.Section(acDetail).BackColor = RGB(255, 105, 180)
        Case Else
            Me.Section(acDetail).BackColor = RGB(238, 238, 209)
    End Select

End Sub


This turned out to be a big hit, and I now have a request from them to alternate between a list of 5-10 specific colors (they are picking them out at the moment!!!).

Is there an small, easy code I can use instead of above to acomplish this?

Thanks in advance

--Ben--

ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forgot a +1:

    ' random:
    Me.Detail.Backcolor = varColors(Int(Rnd()*UBound(varColors)+1))

(°v°)