Add Condition to If ElseIf Statement

gracm25

Registered User.
Local time
Today, 13:40
Joined
Dec 6, 2007
Messages
31
I'd like to add another condition to this code. There is a situation where neither the word "MAJOR" nor "MINOR" appear. In that case, in the ElapsedTimeString field, I'd like the words "ACTION NEEDED" to appear in Bold Green letters. Timeframes don't matter. I don't care how old the situation is. I want all fields that don't say "MAJOR" or "MINOR" to have the "ACTION NEEDED" field inserted. Here's the code: Thanks!!

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim dblInterval As Double

dblInterval = CDbl(dateTimeEnd - dateTimeStart)

Me!ElapsedTimeString.ForeColor = vbBlack
Me!ElapsedTimeString.FontBold = False
Me!ElapsedTimeString.FontUnderline = False

If REPAIR_TYPE = "MINOR" Then
If dblInterval < 1 Then
Me!ElapsedTimeString.ForeColor = vbRed
Me!ElapsedTimeString.FontBold = True
Me!ElapsedTimeString.FontUnderline = True
End If
ElseIf REPAIR_TYPE = "MAJOR" Then
If dblInterval < 1 Then
Me!ElapsedTimeString.ForeColor = vbRed
Me!ElapsedTimeString.FontBold = True
Me!ElapsedTimeString.FontUnderline = True
ElseIf dblInterval >= 1 And dblInterval < 3 Then
Me!ElapsedTimeString.ForeColor = vbBlue
Me!ElapsedTimeString.FontBold = True
Me!ElapsedTimeString.FontUnderline = True
End If
End If
End Sub
 
gracm25,

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim dblInterval As Double

dblInterval = CDbl(dateTimeEnd - dateTimeStart)

Me!ElapsedTimeString.ForeColor = vbBlack
Me!ElapsedTimeString.FontBold = False
Me!ElapsedTimeString.FontUnderline = False

If REPAIR_TYPE = "MINOR" Then
   If dblInterval < 1 Then
      Me!ElapsedTimeString.ForeColor = vbRed
      Me!ElapsedTimeString.FontBold = True
      Me!ElapsedTimeString.FontUnderline = True
   End If
ElseIf REPAIR_TYPE = "MAJOR" Then
   If dblInterval < 1 Then
      Me!ElapsedTimeString.ForeColor = vbRed
      Me!ElapsedTimeString.FontBold = True
      Me!ElapsedTimeString.FontUnderline = True
   ElseIf dblInterval >= 1 And dblInterval < 3 Then
      Me!ElapsedTimeString.ForeColor = vbBlue
      Me!ElapsedTimeString.FontBold = True
      Me!ElapsedTimeString.FontUnderline = True
   Else
      ' Add something here for when "MAJOR", dblInterval >= 3
   End If
Else
   Me!ElapsedTimeString.ForeColor = vbGreen
   Me!ElapsedTimeString.FontBold = True
   Me!ElapsedTimeString = "ACTION NEEDED"
End If

End Sub

Wayne
 
Perfect!! Thank you very much!!
 
You have to register. Click on log in button on homepage and enter your personal information. Then, you'll have access to enter your own threads.
 

Users who are viewing this thread

Back
Top Bottom