troubleshooting Question

issue with conditional foirmatting and code reading a string as a numeric

Avatar of Fordraiders
FordraidersFlag for United States of America asked on
Microsoft AccessVBA
23 Comments3 Solutions100 ViewsLast Modified:
access 2010 vba
sql server

I have a linked that from sql server that has a field  that is stored as a string unfortunately..TARGET_GP

"Line_Color" IS STRING FIELD ALSO , BUT JUST GETTING UPDATED depending on the code, not conditional formatting

So when conditional formatting is looking at the value it does not evaluate correctly when the value is between 0.01 and 9.99
or the code below:

Dim gp As String
  

    If Len(Nz(Me.TARGET_GP, "")) = 0 Then
   Exit Sub
End If
Me!TARGET_GP = Replace([TARGET_GP], "%", "")
Me!TARGET_GP = Replace([TARGET_GP], "..", ".")
If IsNumeric(Me.TARGET_GP) = True Then
    Me.TARGET_GP.Value = Format(Me.TARGET_GP.Value / 100, "0.00%")
End If


If Me!TARGET_GP = "%" Then
Me!TARGET_GP = ""
End If


gp = Me.TARGET_GP.Value



Me!Line_Color = ""


If gp <= "14.99%" Then
  MsgBox "Sorry But the Target_Gp is Below Threshold. Please Correct.", vbCritical, "TARGET THRESHOLD"
  LINE_GP_FAILS = False
  Me.Line_Color = "RED"

End If

' red Light
If gp >= "15.00%" And gp <= "19.99%" Then
  '  MsgBox "RED dave"
    LINE_GP_FAILS = False
    Me.Line_Color = "RED"

End If

' Yellow Light
If gp >= "20.00%" And gp <= "24.99%" Then
  ' MsgBox "yELLOW"
   LINE_GP_FAILS = False
   Me.Line_Color = "YELLOW"

End If

' green light
If gp >= "25.00%" Then
 ' MsgBox "gREEN"
  LINE_GP_FAILS = False
  Me.Line_Color = "GREEN"

End If
   
   
   Exit Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 23 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros