Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On paint event run time error

Status
Not open for further replies.

radder33

IS-IT--Management
Nov 26, 2009
66
DE
Morning All

I am trying to run a bit of vba to colour the cells on a form depending on the content.

I have set the on paint event and put this behind it.

If Me.Completion_.Value = 0 Then
Me.Completion_.BackColor = vbRed
ElseIf Me.Completion_.Value = 100 Then
Me.Completion_.BackColor = vbGreen
Else: Me.Completion_.BackColor = vbYellow
End If

When it runs in a single form its fine but in a continuous form I get a run time debug. Do I have to set something up to cycle through each record?

And if so how would I do that?
 
Why not simply use conditional formatting ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You can use code to set up conditional formatting in a Single View Form, but as PHV suggested, in a Continuous View Form (as well as in Datasheet View) you can really only use Conditional Formatting (from the Menu/Ribbon.) The first two conditions are rather straightforward, utilizing the dropdown boxes, then use the 'Default Formatting,' at the top, for your 'Else' clause.

The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top