Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jun 2001
    Location
    Canton, Ohio, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing Colors in Report detail (Access97/SR1)

    I have a report that lists a percentage on how often a group of records has data. I would like to make all 6 fields for a record change to <font color=red>bold red</font color=red> if a value on that row is less than 50%. I know I can do it in the On_Format event procedure, but using the code found in AccArch46 only allows me to change the BackColor. I'ld like to find a way to change all 6 fields at one time, rather than doing each one individually. I seem to remember seeing a way to "group" the 6 fields using a box or frame, but I can't find the reference again <img src=/S/frown.gif border=0 alt=frown width=15 height=15>!

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Changing Colors in Report detail (Access97/SR1)

    Access doesn't have a way of grouping fields in a frame such that you could change all the controls with 1 line of code (VB does, which is probably what you remember).
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Colors in Report detail (Access97/SR1)

    You can use a collection object to format multiple items with a lot less code than doing them individually. Of course, whether this method is worth your time depends on just how many objects you need to manipulate. You could use something like this:<pre> Dim colControls As New Collection
    colControls.Add txtField1
    colControls.Add txtField2
    colControls.Add txtField3
    colControls.Add txtField4
    colControls.Add txtField5
    colControls.Add txtField6

    Dim varItem As Variant
    For Each varItem In colControls
    With colControls.Item(varItem)
    If .Value < 0.5 Then
    .FontBold = True
    .ForeColor = RGB(255, 0, 0)
    'any other changes you need
    Else
    .FontBold = False
    .ForeColor = RGB(0, 0, 0)
    'any other changes you need
    End If
    Next
    Set colControls = Nothing</pre>

    HTH <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

Posting Permissions

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