Solved Alternate Row Background color, ok easy. What about Alternate Row Text Color? (1 Viewer)

raziel3

Registered User.
Local time
Today, 02:57
Joined
Oct 5, 2017
Messages
275
Getting the alternate row color is easy enough but how do you get alternate row text color?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:57
Joined
May 21, 2018
Messages
8,529
In your query you can add a row number and determine if the row is odd or even.

Row: DCount("*","products","ProductName < '" & [productname] & "'")
IsEven: [row] Mod 2=0

In conditional format
Expression is: [IsEven] = -1
 

raziel3

Registered User.
Local time
Today, 02:57
Joined
Oct 5, 2017
Messages
275
Ok cool, thanks.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:57
Joined
May 21, 2018
Messages
8,529
Demo
 

Attachments

  • RowColor.accdb
    960 KB · Views: 66

raziel3

Registered User.
Local time
Today, 02:57
Joined
Oct 5, 2017
Messages
275
But what about if the query is filtered? The Conditional Formatting wont work.

Filtered.jpg
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:57
Joined
May 21, 2018
Messages
8,529
Depends. If the form is simply built on a filtered list then you base your dcount on the same filtered query not on the table.
If you want to do filters dynamically you will have to build a function that passes in the ID and uses the form's actual recordset to determine the absolute position of the id in the recordset and the function can return odd or even. Then call that function from the query.

IsEven:MyFunctionIsEven([StateID])
Unfortunately I do not have time now to demo.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:57
Joined
May 21, 2018
Messages
8,529
see second example using a hidden control on form
Code:
Public Function IsOddEven(StateID As String) As String
  With Me.RecordsetClone
    .FindFirst "stateID = '" & StateID & "'"
    If .AbsolutePosition Mod 2 = 0 Then
      IsOddEven = "Even"
    Else
      IsOddEven = "Odd"
    End If
  End With
End Function
 

Attachments

  • RowColor2.accdb
    1.2 MB · Views: 74

raziel3

Registered User.
Local time
Today, 02:57
Joined
Oct 5, 2017
Messages
275
Nice. Thanks (y)

So much work to get this functionality. It should be included in the properties window. 🤷‍♂️
 

Users who are viewing this thread

Top Bottom