Results 1 to 3 of 3
  1. #1
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71

    Can VBA see color values from Conditional Formatting

    I have a series of controls that have conditional formatting on them for when a pressure reading is out of range. However, I have the feeling that the conditional formatting isn't really changing the .BackColor value of the the control. Before I go back and use vba script to create the conditional formatting, I want to make sure.



    My questions is: Is there a way to evaluate the color of a control when it's changed by conditional formatting? I want to pop up a MsgBox when an entry is out of range based on the color of the control. I'd use the code below to evaluate for the color.

    Code:
    If ctl.BackColor = RGB(237, 28, 36) And IsNull(Me.CorrectiveActionTxt) Then
    If I can't 'see' the color from a conditional format then so be it - although I'll wish I had checked on this prior to setting up my forms.

    Thanks for the help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I have never asked Access what the BackColor of a control is after conditional formatting. I would imagine it would return its true value.

    Instead of the built in RGB function I use VBA's number translation for RGB or them this, or whatever the control properties are.

    Code:
    Dim strColor As String
    strColor = Me.cmdOne.BackColor
    strColor = "cmdOne.BackColor = " & strColor
    Debug.Print strColor
    
    Dim strBorder As String
    strBorder = Me.cmdOne.BorderColor
    strBorder = "cmdOne.BorderColor = " & strBorder
    Debug.Print strBorder
    You could use code like this to compare before and after conditional formatting. This should let you know what VBA thinks the value of a control is at a particular time. Then, knowing what event to place your If Then statement, you could see if the RGB condition is met or not.

  3. #3
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71
    It's me: Thanks for the code. Now I can see what color VBA needs and I can confirm that as far as scripting is concerned a conditional format to the background color isn't changing the color. Before data entry and regardless of what the conditional format does, the script returns the number for white.

    Thanks a lot for the help.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-26-2013, 09:10 PM
  2. Replies: 1
    Last Post: 11-02-2011, 03:15 AM
  3. Replies: 1
    Last Post: 12-14-2010, 10:03 PM
  4. Conditional Formatting date due color
    By Desstro in forum Programming
    Replies: 1
    Last Post: 12-08-2010, 11:12 PM
  5. Replies: 0
    Last Post: 11-13-2009, 10:18 AM

Tags for this Thread

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