Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2011
    Posts
    42

    Unanswered: timetable highlighting

    in one report I have :
    1) employee_name , 2) start_date, 3) end_date
    against these controls i have the months (Jan, feb..... to dec.) as
    I'd like to highlite down these months (in color) based on the dates

    How possible this is ?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I'll suppose that the months consist in Labels: Label_Jan to Label_Dec. Each label has its Tag property set to the number of the month it represents (Label_Jan.Tag = 1, Label_Feb.Tag = 2, etc.). Each label has also its BackColor property set to the colour I want to use for highlight, Red in my example (=255) and its BackStyle property set to Transparent (=0: Default).

    The following code will highlight in red each label that represents a month in the interval of dates determined by Text_Start_Date and Text_End_Date every time the contents of one of these two textboxes is changed:
    Code:
    Private Sub Text_End_Date_AfterUpdate()
    
        AdjustLabels
    
    End Sub
    
    Private Sub Text_Start_Date_AfterUpdate()
    
        AdjustLabels
    
    End Sub
    
    Private Function AdjustLabels()
    
        Dim ctl As Control
        
        For Each ctl In Me.Controls
            If (Val(ctl.Tag) >= DatePart("m", Me.Text_Start_Date.Value)) And (Val(ctl.Tag) <= DatePart("m", Me.Text_End_Date.Value)) Then
                ctl.BackStyle = 1    '  Normal --> Highlight.
            Else
                ctl.BackStyle = 0    ' Transparent.
            End If
        Next ctl
        
    End Function
    Have a nice day!

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what version of Access are you using?..
    This may give you some ideas if you use A2003/XP, but it doesn't work in A2010
    Attached Files Attached Files
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Mar 2011
    Posts
    42
    I'm using access 2007

  5. #5
    Join Date
    Mar 2011
    Posts
    42
    Dear Healdem,
    the report is giving an error message "you can't assign a value to this control"

    Thanks

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    yup, quite possible, I know it worked in A2003, but something changed in Access between 2003 & 2007.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •