Condition Formatting question

Johnny5Alive

New member
Local time
Today, 22:11
Joined
Aug 29, 2003
Messages
5
I have a report that shows a date raw material is due to come in. Then I have an expression field that shows the "Todays Date".

I want to put a condition so that when the due date of material is equal to the Todays Date field, the text will turn red. Kind of like an alert system.

So I selected my field I want the condition on. And entered all my information for the condition. But its not working.

So my question is: Can date fields even have conditions?
 
Try this...
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.YourDueDateOfMaterialField = Me.YourTodaysDateField Then
      Me.YourDueDateOfMaterialField.FontBold = True
      Me.YourDueDateOfMaterialField.ForeColor = vbRed
Else
      Me.YourDueDateOfMaterialField.FontBold = False
      Me.YourDueDateOfMaterialField.ForeColor = vbBlack
End If

End Sub

IMO
 
ah.. youre gonna kill me,

Im not really advanced yet. Where do I put that code? Thanks

john
 
Ok, Open the report in design view, Goto View >> Code, copy and paste the code I sent under the line " Option Compare Database" not forgetting to change "YourDueDateOfMaterialField" and "YourTodaysDateField " to the names of the relevent TextBoxes.

IMO
 
IMO said:
Ok, Open the report in design view, Goto View >> Code, copy and paste the code I sent under the line " Option Compare Database" not forgetting to change "YourDueDateOfMaterialField" and "YourTodaysDateField " to the names of the relevent TextBoxes.

IMO

Thanks IMO,

It works. Is it possible to add "= or less than" to the equation.

Thanks for your help. My first sucessful code entry.

John
 
You've already used "=" but you can use "<" or ">" like...
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.YourDueDateOfMaterialField = Me.YourTodaysDateField Then
      Me.YourDueDateOfMaterialField.FontBold = True
      Me.YourDueDateOfMaterialField.ForeColor = vbRed
End If 

     If Me.YourDueDateOfMaterialField > Me.YourTodaysDateField Then
           Me.YourDueDateOfMaterialField.FontBold = True
           Me.YourDueDateOfMaterialField.ForeColor = vbYellow
     End If   

          If Me.YourDueDateOfMaterialField < Me.YourTodaysDateField Then
                Me.YourDueDateOfMaterialField.FontBold = True
                Me.YourDueDateOfMaterialField.ForeColor = vbBlue
          End If  

End Sub

IMO
 
Last edited:
oh boy...

Okay, I am able to get one function to work but whenever I try 2, then nothing happens. Heres my code. Anything wrong with it?

If Me.Date_Ordered = Me.Todays_Date Then
Me.Date_Ordered.FontBold = True
Me.Date_Ordered.ForeColor = vbRed

If Me.Date_Ordered < Me.Todays_Date Then
Me.Date_Ordered.FontBold = True
Me.Date_Ordered.ForeColor = vbRed

Else
Me.Date_Ordered.FontBold = False
Me.Date_Ordered.ForeColor = vbBlack

End If
End If


End Sub
 
Here you are...
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.Date_Ordered = Me.Todays_Date Then
      Me.Date_Ordered.FontBold = True
      Me.Date_Ordered.ForeColor = vbRed
End If 

     If Me.Date_Ordered < Me.Todays_Date Then
           Me.Date_Ordered.FontBold = True
           Me.Date_Ordered.ForeColor = vbRed
     End If   

          If Me.Date_Ordered > Me.Todays_Date Then
                Me.Date_Ordered.FontBold = False
                Me.Date_Ordered.ForeColor = vbBlack
          End If  

End Sub

IMO
 

Users who are viewing this thread

Back
Top Bottom