Alternating BackColor

cnodadmo

Registered User.
Local time
Today, 12:53
Joined
Aug 11, 2012
Messages
12
Is there a way to only highlight the last row of the detail section in a report?

I tried the following code in the "Format" but could not get it to work in Access 2010.

If Me.ClaimStatuses = "Total Potential Recoverable" Then
Me.Section(acDetail).BackColor = vbYellow
Else
Me.Section(acDetail).BackColor = vbWhite
End If

Where "ClaimStatuses" is the control text box and "Total Potential Recoverable" is the value I want to equal so this row which is the last row will be yellow.
 
This statements will highlight the detail section for current record:
Code:
Option Compare Database
Option Explicit

Dim curID As Integer

Private Sub Detail_Paint()
    With Me
        If .ID_PT = curID Then
            .Detail.BackColor = 16776960
        Else
            .Detail.BackColor = 16777215
        End If
    End With
End Sub
 
Private Sub Form_Current()
    curID = Nz(Me.ID_PT, 0)
End Sub

The ID_PT is a control in my form (and a field on the table) that store the IDs.
Of course that you can perform other tests in the If Then Else statement.
Good luck !
 
Thanks that worked beautifully. Now, I'm also trying to bold the text for that row. I tried

If ... Then
.Detail.BackColor = 1234567
.FontBold = True
Else
.Detail.BackColor = 2345679
End If

But it was giving me an error.
 
Maybe
.Detail.FontBold if this option exist for the detail section
 
I think that your need is to know, in a continuous form, where the cursor is.
I use for this the conditional formatting for controls.
If the control has focus the back color for that control become yellow.
 

Users who are viewing this thread

Back
Top Bottom