From: Dee on 18 May 2010 17:54 I am trying to get a field to turn red if the condition is "High" I tried using the conditional formatting and it does not work. I also tried using the below vba code and this does not work either. I tried it in the after update procedure and the on current procedure with no luck. Could this be an Access bug? Private Sub Critical_AfterUpdate() If Me.Critical = "High" Then Me.Critical.ForeColor = vbRed End If End Sub
From: Al Campagna on 18 May 2010 19:12 Dee, Is Critical a manually entered text control? Or a Combo... or a List? Is it bound to a text field? Details please... Your code, although faulty (so far), should have (at least) turned Critical to red after an update with "High" See below for further tweaking of that code... Also, what version of Access are you using... and if 2000 or greater... have you tried Conditional Formatting? ------------------ You'll also need to indicate what color you want Critical, if it's not "High." Otherwise, once you've turned Critical red, and go to another record... that value will be red too... regardless whether it's "High" or not. And... you'll also need to have that same code in the OnCurrent event of the form, so that when you arrive at a record with Critical = "High", the text is made red. And if not, the text would be made black. Private Sub Critical_AfterUpdate() If Me.Critical = "High" Then Me.Critical.ForeColor = vbRed Else Me.Critical.ForeColor = vbBlack End If > End Sub -- hth Al Campagna Microsoft Access MVP 2007-2009 http://home.comcast.net/~cccsolutions/index.html "Find a job that you love... and you'll never work a day in your life." "Dee" <Dee(a)discussions.microsoft.com> wrote in message news:82EC939E-2F44-4F2F-B1FA-0564955A6E1D(a)microsoft.com... >I am trying to get a field to turn red if the condition is "High" > I tried using the conditional formatting and it does not work. I also > tried > using the below vba code and this does not work either. I tried it in the > after update procedure and the on current procedure with no luck. Could > this > be an Access bug? > > Private Sub Critical_AfterUpdate() > If Me.Critical = "High" Then > Me.Critical.ForeColor = vbRed > End If > End Sub
|
Pages: 1 Prev: Combo Box - cursor automatically inserted instead of scrolling thr Next: Sum & Count on Form. |