Can I bold a field in a report if it meets criteria?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tmoon3
    New Member
    • Feb 2008
    • 5

    Can I bold a field in a report if it meets criteria?

    Hello All,
    I have a report where it lista employees that need to have an eval done in the next 30 days.

    If the employee has a 3 month, 6 month or 12 month eval due in the next 30 days it lists the employee name, 3 month eval due date, 3 month eval score, 6 month eval due date, 6 month eval score, and 12 month eval due date and score. I would like the report to bold or highlight either the 3, 6 or 12 month eval due date that made teh ee hit the report criteria, and I cannot seem to get to to work ... So for each ee in the list one of the due dates would be in BOLD or have a red background... (Which i have tried in the ON Open event of the form.

    here is my code...

    [CODE=vb]Private Sub Report_Open(Can cel As Integer)
    Dim strDivision As String
    Dim strTerm As String
    Dim strEmpType As String
    Dim dteCurrentdate As Date

    'Open the form to get the variables
    DoCmd.OpenForm "SelectReportCr iteriaEval", acNorman, , , , acDialog

    ' Get the Seleceted Values
    strDivision = Nz(Forms("Selec tReportCriteria Eval")!selDivis ion, " ")
    strTerm = "N"
    strEmpType = "Temp"
    dteCurrentdate = DateAdd("m", 1, Date)
    'MsgBox "strDivisio n = " & strDivision

    ' Set the recordsource for the report
    If strDivision <> "ALL" Then
    Me.RecordSource = "SELECT * FROM Main_EE_Info " & _
    "WHERE Division = '" & strDivision & "' " & _
    "AND EmpType LIKE '[" & strEmpType & "]*' " & _
    "AND Terminated Like '" & strTerm & "' " & _
    "AND ((The3MEvalDate <= #" & dteCurrentdate & "# AND The3MEvalScoreF lag = 'N') OR " & _
    "(The6MEval Date <= #" & dteCurrentdate & "# AND The6MEvalScoreF lag = 'N') OR " & _
    "(The12MEvalDat e <= #" & dteCurrentdate & "# AND The12MEvalScore Flag = 'N'))"
    Else
    Me.RecordSource = "SELECT * FROM Main_EE_Info " & _
    "WHERE EmpType LIKE '[" & strEmpType & "]*' " & _
    "AND Terminated Like '" & strTerm & "' " & _
    "AND ((The3MEvalDate <= #" & dteCurrentdate & "# AND The3MEvalScoreF lag = 'N') OR " & _
    "(The6MEval Date <= #" & dteCurrentdate & "# AND The6MEvalScoreF lag = 'N') OR " & _
    "(The12MEvalDat e <= #" & dteCurrentdate & "# AND The12MEvalScore Flag = 'N'))"

    End If

    'MsgBox "Me.RecordSourc e = " & Me.RecordSource

    ' MsgBox "Me.Date = " & FThe3MEvalDate

    ' MsgBox "Me.Date = " & dteCurrentdate

    If The3MEvalDate <= dteCurrentdate Then
    If The3MEvalScoreF lag = "N" Then
    Me.FThe3MEvalDa te.BackColor = "RED"
    End If
    End If
    If The6MEvalDate <= dteCurrentdate Then
    If The6MEvalScoreF lag = "N" Then
    Me.FThe6MEvalDa te.BackColor = "RED"
    End If
    End If
    If The12MEvalDate <= dteCurrentdate Then
    If The12MEvalScore Flag = "N" Then
    Me.FThe12MEvalD ate.BackColor = "RED"
    End If
    End If

    DoCmd.Close acForm, "SelectReportCr iteriaEval"
    End Sub[/CODE]


    Any help would be greatly appreciated... I am sure I ma just putting this in the wrong event or somethign but It is Friday and my head hurts so I am posting as a last resort!

    THANK YOU!
    Last edited by Scott Price; Feb 15 '08, 10:54 PM. Reason: Code Tags
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Assuming you're running ACC2000 or later, you can do this using Conditional Formatting, just like you would in a form.

    Linq ;0)>

    Comment

    • mshmyob
      Recognized Expert Contributor
      • Jan 2008
      • 903

      #3
      Linq's suggestion is easiest and I would also recommend it but if you still want to code it try the following:

      [CODE=vb]
      Dim vRed as Long
      vRed RGB(255,0,0)
      Me!txtControl.B ackColor = vRed
      [/CODE]

      Comment

      • Stewart Ross
        Recognized Expert Moderator Specialist
        • Feb 2008
        • 2545

        #4
        If you still need to apply bold to a control the hard way without using conditional formatting or setting the background place an expression like this in the on-format event of the section of your report in which the controls you need to highlight are placed:

        Code:
         If (condition you are testing) then 
        	Me.[name of the control you want to embolden].Fontbold = True
        else
        	Me.[name of the control you want to embolden].Fontbold = False
        Endif
        If your condition is easily readable and understandable you could shorten this to
        Code:
         
        Me.[name of the control you want to embolden].Fontbold = (condition you are testing)
        -Stewart

        Comment

        • tmoon3
          New Member
          • Feb 2008
          • 5

          #5
          Thanks to all! (I have had the flu and just now gettign back to work)

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            Glad we could help! Hope you're feeling better!

            Linq ;0)>

            Comment

            • Scott Price
              Recognized Expert Top Contributor
              • Jul 2007
              • 1384

              #7
              Bold-ing a control will make all the text in the control bold, or the color specified. If you are interested in only making one word in a multi-word string bold or a different color, there is a module that I found somewhere and use quite a bit that does just this. If you're interested in it, let me know and I'll dig it out, polish it up and post it :-)

              Regards,
              Scott

              Comment

              Working...