Results 1 to 10 of 10
  1. #1
    txmmoore is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    5

    Just doesn't seem to work!

    I have a report where the Detail field comes from a query. I perform some calculations and place the data in a field [Text55] When this field is above 99% (0.99)
    I want to highlight the background name of the person who achieve this by changing the background color. Here is my code is below. The problem is all the fields are either yellow with the exception of the first one, or they don't change at all. Also, where do I place this code? OnFormat, OnPaint, etc. Right now I have it in the OnPrint field in the Detail. Does not work. As of now, there here is the data for the [text55] field:

    0.901
    1.24
    0.55
    0.89
    1.09
    1.78

    I only have 3 records greater than 0.99, but it highlights them all. I just can't seem to figure this out. Please tell me I'm an idiot and show me what I'm
    dong wrong. Thank you!

    Dim lngcolor As Long
    Dim testvalue As Single
    lngcolor = RGB(255, 255, 255)
    If IsNull(Me!Text55) Then
    Exit Sub
    Else


    If Me!Text55 > 0.99 Then
    Me!ManRepName.BackColor = lngcolor
    End If
    End If

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'd use Conditional Formatting, or in code the detail format event. That said, your problem is no Else clause for this If:

    If Me!Text55 > 0.99 Then

    telling it what to do if the value is less than .99.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    txmmoore is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    5
    Thank you. But, perhaps I did not give enough information. My report varies in length, so for information purposes only, I will use this as an example; I have a field [ManRepName] and a performance factor [Text55]. The Text55 is a calculated field, so the results may vary. As of now, the report is working perfect. But, what I'm trying to do is spazz it up a little so that if the performance of the individual is greater than 99% (0.99) then I want to highlight the ManRepName. I have placed conditional formatting on the Text55, so if the value is greater than 99% it changes color. But, I want the ManRepName to change color as well. I cannot put this in a conditional format, as you can only work with the field you want changed (i think). Since I am changing another field, then brings in the problem. I have placed my code just about everywhere on the report, and get nothing.

    Maybe I'm just not seeing it, so that is why I am turning to the MS ACCESS folks for this. Please help! Any information will be greatly appreciated!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well, the code certainly needs the Else clause I mentioned to work. You have to tell it what you want done when the value is less than .99. You can use Conditional Formatting on a different textbox, you just use Expression Is.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    txmmoore is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    5
    Thank you! I have done the following, and provided examples. I took your advice and change my code to:
    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Dim lngcoloryellow, lngcolorwhite As Long
    Dim testvalue As Single
    lngcoloryellow = RGB(255, 255, 0)
    lngcolorwhite = RGB(255, 255, 255)

    If IsNull(Me!Text55) Then
    Exit Sub
    Else
    If Me!Text55 > 1 Then
    Me!ManRepName.BackColor = lngcoloryellow
    Else
    Me!ManRepName.BackColor = lngcolorwhite
    End If
    End If
    End Sub


    I put the "1" in the if statement, as we are starting a new year and no one has gotten to 100% yet. My current data [Text55] has 3 numbers greater than 1 and the
    rest are still zero. This did not work. All lines are still "white". I was hoping to get at least 3 yellows!

    Then I tried your condtional formatting. I am a little new to this, but this is what I put:

    Expression Is [Text55]>1

    This did not work either. Anything that I maybe missing, let me know. This has baffled me for 2 weeks now!
    Thank you!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If the values are percentages, wouldn't you want to test for .01?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    txmmoore is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    5
    Thank you. You are correct, and I did notice that. It seems to be working on the conditional formatting now. My only problems is that
    in the report, I have something like 30 columns and 16 sub reports that I have to place the conditional format in. Going to be a long night!
    Thank you again for your input. I will be posting again as I have a graphing problem with another report.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help. If they get the same format, I think you can select multiple controls and then go into CF. Worth a try anyway. That may also be a reason to go the code route, since you can either list the controls or loop them.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    txmmoore is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    5
    Thats why I wanted the code version so I could just copy and paste. Never could get the code to work. Frustrating!

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The last code looked about right, except for the .01/1 problem. As mentioned earlier, I would have it in the detail format event.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Can't Figure Out Why Code Doesn't Work
    By nosmoke in forum Programming
    Replies: 3
    Last Post: 09-26-2013, 12:23 PM
  2. Buttons doesn't work in Subforms
    By fedesc in forum Access
    Replies: 6
    Last Post: 09-25-2011, 12:58 AM
  3. App doesn't work with runtime
    By bubba55 in forum Access
    Replies: 0
    Last Post: 09-21-2011, 08:33 AM
  4. Can Grow doesn't work
    By gg80 in forum Reports
    Replies: 6
    Last Post: 05-13-2011, 07:14 PM
  5. Query doesn't work the day after
    By sithis876 in forum Queries
    Replies: 1
    Last Post: 07-13-2010, 07:11 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