Results 1 to 3 of 3
  1. #1
    rivereridanus is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    71

    Change record design for each record based on calculation

    I have a custom report whose dataset is just a table. For each record in the table, the report properly shows up. However, I need to make colored dials visible based on each record (think stoplight- red,green,yellow circles). When I do this on the report it colors the appropriate circle, but only for the first record. All the other dials are given a circle the same color as the one which was correctly calculated for the first record.



    Is there a way to have access re-run the ChangeColor sub and change the image for each individual record on the report instead only running once coloring them all the same?


    Code:
    Private Sub Report_Load()
        'FILL METADATA
        Owner = DLookup("DialOwner", "tblMetadata", "DialName = 'Risk Maturity'")
        sponsor = DLookup("DialSponsor", "tblMetadata", "DialName = 'Risk Maturity'")
        If sponsor & "" = "" Then
            sponsor = "N/A"
        End If
        Me.Label33.Caption = "Dial Owner: " & Owner
        Me.Label34.Caption = "Dial Sponsor: " & sponsor
        
        'GET COLOR
        ChangeColor
    End Sub
    
    Private Sub ChangeColor()
    On Error Resume Next
        riskavg = CDbl(Me.RiskMaturity.value) / 100
        'lookup the threshold info for selected year
            riskThreshGreen = DLookup("Green", "tblThresholds", "Metric = 'Risk Maturity'")
            riskThreshYellow = DLookup("Yellow", "tblThresholds", "Metric = 'Risk Maturity'")
            
            If (riskavg > riskThreshGreen Or riskavg = riskThreshGreen) Then
                'MAKE DIAL GREEN
                Me.Image35.Visible = True
                Me.Image36.Visible = False
                Me.Image37.Visible = False
            ElseIf (riskavg > riskThreshYellow Or riskavg = riskThreshYellow) Then
                'MAKE DIAL YELLOW
                Me.Image35.Visible = False
                Me.Image36.Visible = True
                Me.Image37.Visible = False
            Else:
                'MAKE DIAL RED
                Me.Image35.Visible = False
                Me.Image36.Visible = False
                Me.Image37.Visible = True
            End If
    End Sub

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Put the code into the "OnFormat" of the Detail.

  3. #3
    rivereridanus is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    71
    That's exactly what I needed- Thanks!

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

Similar Threads

  1. Replies: 40
    Last Post: 08-20-2013, 11:38 PM
  2. Record selection based on calculation
    By WEJ in forum Programming
    Replies: 5
    Last Post: 05-30-2013, 01:05 PM
  3. Replies: 3
    Last Post: 08-21-2012, 01:10 PM
  4. Replies: 0
    Last Post: 04-18-2011, 01:01 PM
  5. duplicate record based on calculation
    By Coolpapabell in forum Queries
    Replies: 4
    Last Post: 08-06-2009, 07:53 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