Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2010
    Location
    Huntsville, Alabama
    Posts
    11

    Question Unanswered: MS VB Color Changes

    Greetings,

    I am trying to change the color on a calculated field whenever it returns a negative answer. See below:

    ' If delta less than zero color field so someone notices
    If cydelta < 0 Then
    ' Me!cy_delta.BackColor = RGB(255, 0, 0) ' Color - Red
    Me!cy_delta.BackColor = "CC0033" ' Color - Red
    Me!cy_delta.ForeColor = RGB(255, 255, 0) ' Font Color - Yellow
    Else
    Me!cy_delta.BackColor = RGB(255, 255, 255) ' Color = White
    End If

    When I use the 'RGB' color set I have no problem, but you see where I tried to change the BackColor using a hexadecimal color code but when this executed I received a type 13 mismatch error. Am I limited to using the RGB Color codes? If not, what is wrong with the hexadecimal entry in the code above? I thought that was the proper way to assign a hexadecimal color code. Is it because I have a hexadecimal in one line and the RGB color in the next line that causes the mismatch?

    As you can see, I am a little confused right now, and any/all assistance is greatly appreciated.

    DBH sends

  2. #2
    Join Date
    Aug 2010
    Location
    Huntsville, Alabama
    Posts
    11

    Disregard, I am an idiot!!

    Sorry for that folks, I'm an idiot and my last post proves it...
    I figured out my problem, turns out that MS Access has it's own personal set of color codes, different from the hexidecimal or RGB. I guess if you live long enough you will learn some new things, for me though, it is an every day sort of learning experience.

    Only the US Federal Government would have placed me where I am today. I am a degreed software engineer with over 25 years experience, but in its infinite wisdom, the US Government felt I would be better suited as a Financial Analyst, go figure. So, now I am spending a lot of time creating databases and spreadsheets, to automate a large portion of what we do as Financial Analysts. I wonder when my Financial Analyst duties will kick in, probably right after I finish developing the application I am currently developing.

    Thanks anyway though, and I will be back, count on it....

  3. #3
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I don't see how a string could be interpreted as a numeric value in any base (decimal, octal, hexadecimal or other), at least without a proper prefix to specify which base to use. This works in VB/VBA:
    Code:
    Me!cy_delta.BackColor = &hCC0033 ' Color - Red
    However it's a dark-blue hue.
    Have a nice day!

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    As Sinndho has said, the string "CC0033" cannot be interpreted as a numeric expression, which the property BackColor requires and hence the type 13 mismatch error.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •