Results 1 to 7 of 7
  1. #1
    rwahdan1978 is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Jun 2024
    Posts
    57

    Thumbs up Change row color in report

    Hi,

    I have the below report and I would like to change the color of the raw that has the lastest "TheTime" filed, how to do that?

    Click image for larger version. 

Name:	Untitled.png 
Views:	19 
Size:	21.3 KB 
ID:	51850

    I have the code to get the last record in the table:

    Dim rs As Recordset
    Set rs = CurrentDb.OpenRecordset("SELECT TOP 1 * FROM Turns ORDER BY ID DESC")
    MsgBox ("Last Turn: " & rs!Person & " On " & rs!TheTime)
    rs.Close


    Set rs = Nothing

    now how to change the color of the raw with the data selected?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    AFAIK, cannot conditionally change row color.
    Can use Conditional Formatting to change Backcolor of textboxes. Changing 'row' color involves a textbox sized full width of row sitting behind other controls.
    Or VBA in report Detail Format event can conditionally change Backcolor of a label sized full width of row sitting behind other controls.
    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.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    I would perhaps try with a Max(TheDate) for the Person in the query, either as part of the report query source or as a separate query linked to the report query.

    Code:
    SELECT tblDaily.DailyDate, Max(tblDaily.CarbsCalc) AS MaxOfCarbsCalc
    FROM tblDaily
    GROUP BY tblDaily.DailyDate;
    Then test if controls are the same value.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,880
    Is date and time one field in the table or two?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    rwahdan1978 is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Jun 2024
    Posts
    57

    Re

    Quote Originally Posted by moke123 View Post
    Is date and time one field in the table or two?
    2 separate fields

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,880
    I would probably use one field and if you need to display them separately you can use format(), DateValue(), or TimeValue().

    https://www.techonthenet.com/access/functions/index.php
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    As an alternative to using conditional formatting, investigate using the detail onprint event

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

Similar Threads

  1. Replies: 3
    Last Post: 03-06-2023, 12:31 PM
  2. Replies: 6
    Last Post: 06-08-2020, 01:54 PM
  3. Change Color of Box on Report based off Value
    By Nuke1096 in forum Access
    Replies: 10
    Last Post: 01-29-2014, 02:47 PM
  4. Replies: 3
    Last Post: 05-30-2013, 08:03 AM
  5. Replies: 4
    Last Post: 12-25-2011, 06:31 PM

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