Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Format Detail Section Font Color (Access 2000 VBA)

    I want to format the font color of the detail section of a report based on the date field in that detail section. So if past due - blue color, if same day - green color.

    What is the easiest way to do this.

    Thanks,

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Format Detail Section Font Color (Access 2000 VBA)

    Um, a section of a report doesn't have a font color. Controls such as a text box do. Do you mean that you want to change the font color for all controls in the Detail section?

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Format Detail Section Font Color (Access 2000 VBA)

    Yes, all the controls in the detailed section based on the value of the date_due control in the detail section.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Format Detail Section Font Color (Access 2000 VBA)

    You could use something like this in the On Format event of the Detail section:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim ctl As Control
    Dim lngColor As Long
    ' Determine the color to use
    If Me.Date_due < Date Then
    lngColor = vbRed
    Else
    lngColor = vbBlack
    End If
    ' Avoid problems with controls that don't have a font color
    On Error Resume Next
    ' Loop through all controls to set the color
    For Each ctl In Me.Controls
    ctl.ForeColor = lngColor
    Next ctl
    Set clt = Nothing
    End Sub

    Change the condition as needed, and the colors too

  5. #5
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Format Detail Section Font Color (Access 2000 VBA)

    Thanks Hans,

    How come it formats the color of the footer and page header also. Is there a way to just do the detail section.

    Deni

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Format Detail Section Font Color (Access 2000 VBA)

    Oops, sorry, I was distracted and posted code without checking it. Change

    For Each ctl In Me.Controls

    to

    For Each ctl In Me.Detail.Controls

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Format Detail Section Font Color (Access 2000 VBA)

    Are you sure you can't set the background colour of the detail section? I seem to remember i could.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Format Detail Section Font Color (Access 2000 VBA)

    Yes, you can set the background color of a section (it's the BackColor property), but you cannot set the font color of a section (ForeColor is not a property of a section).

  9. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Format Detail Section Font Color (Access 2000 VBA)

    Thanks, i missed that.

Posting Permissions

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