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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hihglighting text with multiple criteria

Status
Not open for further replies.

smoker1

Programmer
Jun 18, 2001
76
US
Hello! I am trying to create code that looks at the time and highlights it if it is either under or over the goal times indicated.

Here is my code in the "On Print":

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim goal As Date
goal = CDate(Format(txtDailyMinimumGoal))
Debug.Print goal
Debug.Print Me!txtDailyMinimumGoal
If CDate(Me!txtBreak) < goal Then
Me!txtBreak.BackColor = 14935011
Else
Me!txtBreak.BackColor = 16777215
End If

Dim goal As Date
goal = CDate(Format(txtDailyMaximumGoal))
If CDate(Me!txtBreak) > goal Then
Me!txtBreak.BackColor = 14935011
Else
Me!txtBreak.BackColor = 16777215
End If

End Sub

Unfortunately, it only highlights the first set of code - so I need to somehow combine the two. Can anyone assist?
 
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim goalmax As Date, GoalMin as date
goal = CDate(Format(txtDailyMinimumGoal))
goalmin = CDate(Format(txtDailyMaximumGoal))

If CDate(Me!txtBreak) < goalmax Then
Me!txtBreak.BackColor = 14935011
Else if CDate(Me!txtBreak) > goalmin Then
Me!txtBreak.BackColor = 14935011
Else
Me!txtBreak.BackColor = 16777215
End If
End Sub
 
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim goalmax As Date, GoalMin as date
goalmax = CDate(Format(txtDailyMinimumGoal))
goalmin = CDate(Format(txtDailyMaximumGoal))

If CDate(Me!txtBreak) < goalmax Then
Me!txtBreak.BackColor = 14935011
Else if CDate(Me!txtBreak) > goalmin Then
Me!txtBreak.BackColor = 14935011
Else
Me!txtBreak.BackColor = 16777215
End If
End Sub
 
I think you're very close to resolving this for me in your last posting. However, after I cut your code into my code builder, I receive a message highlighting the &quot;else if cdate(me!txtBreak) >goalmin Then&quot; statement and stating that it &quot;must be first statement on the line&quot;. When I separate the Else statement, it doesn't work. Any ideas?

Thanks so much for your help!!!


--Angela
 
don't put space in else if needs to be elseif

If CDate(Me!txtBreak) < goalmax Then
Me!txtBreak.BackColor = 14935011
Elseif CDate(Me!txtBreak) > goalmin Then
Me!txtBreak.BackColor = 14935011
Else
Me!txtBreak.BackColor = 16777215
End If
End Sub
 
Thank you very much for your great assistance! It is greatly appreciated!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top