Solved

Converting Hex code to Access color Display

Posted on 2004-09-08
3
932 Views
Last Modified: 2008-02-01
I have an Access Database and I need a little programming done. I have a field where a hex code is inputted, ie #000000 and I need Access to take that code and convert it into the appropriate color. Then display the color in a box. I have tried to do this, but I can't seem to get Access to display the appropriate color in the box. I know my vb is off somewhere, I just don't know where. Currently I have 3 main fields in use, a Color Name Field that is Unbound, a Color Code field that holds the Hex code, and the Color Number field, that should display the appropriate color that Access uses. I also have a box that is named ColorView, and it should display the information from the Color Number field. Everything works except the conversion from Hex to Number is wrong. For instance Now, if you input the Hex code of #0000FF you get the number 255 and the color Red. What you should get is the color Blue and the number 16711680. Please Help.
0
Comment
Question by:peanutoma
3 Comments
 
LVL 34

Expert Comment

by:flavo
ID: 12011872
Access (97) has these colours

0      Black      8      Gray
1      Blue      9      Light Blue
2      Green      10      Light Green
3      Cyan      11      Light Cyan
4      Red      12      Light Red
5      Magenta      13      Light Magenta
6      Yellow      14      Light Yellow
7      White      15      Bright White


can use QBColor(color) to return the number of the colour

ie

QBColor(1) 'blue =  16711680

QbColor returns a Long representing the RGB color code corresponding to the specified color number.
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 500 total points
ID: 12011903
Reverse the field. If the text is always input in a consistant format (#000000), you can do this:

lngColor=Val("&h" & Right$(MyColorStr,2) & Mid$(MyColorStr,4,2) & Mid$(MyColorStr,2,2))

That should give you Access' RGB color.
0
 

Author Comment

by:peanutoma
ID: 12012580
Let me try them out and see if they work for what I want to do.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now