Results 1 to 4 of 4
  1. #1
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659

    Even Odd row formatting

    I am trying to change the back color of each row on a report depending what row number it is on.



    I am trying to use a Rectangle with controls over top of it, the controls have their background style set to transparent.

    my Code says.
    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Static Counter: Counter = Nz(Counter, 1)
        Counter = Counter + 1
        If Counter Mod 2 = 0 Then
            ColorBox(FormatCount).BackColor = vbWhite
        Else
            ColorBox(FormatCount).BackColor = 12632256
        End If
    End Sub
    How do I correctly set the backcolor of a rectangle when the report is being formatted? Or should I use a different control for the backcolor?

    Thanks for your time

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Figured it out
    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Static Counter: Counter = Nz(Counter, 1)
        Counter = Counter + 1
        If Counter Mod 2 = 0 Then
            Me.Section(acDetail).BackColor = vbWhite
        Else
            Me.Section(acDetail).BackColor = 12632256
        End If
    End Sub

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Note to Access 2007 and up users. Report detail section has a property for Alternate Back Color that should accomplish the same result as the code in Access 2003.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    That makes me feel a lot more sane. I was looking for the option at first and felt stupid that I had to code this .

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Conditional Formatting
    By schwabe in forum Reports
    Replies: 2
    Last Post: 02-01-2012, 10:28 AM
  2. Conditional Formatting vs. VBA Formatting
    By gopherking in forum Reports
    Replies: 5
    Last Post: 11-09-2011, 06:53 PM
  3. Between formatting
    By reidn in forum Queries
    Replies: 2
    Last Post: 07-21-2011, 12:11 PM
  4. Conditional formatting
    By avarusbrightfyre in forum Forms
    Replies: 3
    Last Post: 07-01-2011, 11:18 AM
  5. Table Formatting
    By chrisjack001 in forum Database Design
    Replies: 4
    Last Post: 10-13-2010, 07:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums