Solved Alternate Row Background color, ok easy. What about Alternate Row Text Color?

raziel3

Registered User.
Local time
Today, 18:38
Joined
Oct 5, 2017
Messages
311
Getting the alternate row color is easy enough but how do you get alternate row text color?
 
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
 
Ok cool, thanks.
 
But what about if the query is filtered? The Conditional Formatting wont work.

Filtered.jpg
 
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.
 
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

Nice. Thanks (y)

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

Users who are viewing this thread

Back
Top Bottom